本文整理汇总了PHP中OC_Calendar_Calendar类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Calendar类的具体用法?PHP OC_Calendar_Calendar怎么用?PHP OC_Calendar_Calendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Calendar_Calendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testBasic
function testBasic()
{
$uid = uniqid();
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
OC_User::setUserId($uid);
$calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 1);
$this->assertEquals($all[0]['id'], $calId1);
$this->assertEquals($all[0]['displayname'], 'test');
$this->assertEquals($all[0]['uri'], 'test');
$this->assertEquals($uid, $all[0]['userid']);
$calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$this->assertNotEquals($calId1, $calId2);
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 2);
$this->assertEquals($all[1]['id'], $calId2);
$this->assertEquals($all[1]['displayname'], 'test');
$this->assertEquals($all[1]['uri'], 'test1');
//$cal1=OC_Calendar_Calendar::find($calId1);
//$this->assertEquals($cal1,$all[0]);
OC_Calendar_Calendar::deleteCalendar($calId1);
OC_Calendar_Calendar::deleteCalendar($calId2);
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:calendar.php
示例2: import
function import()
{
switch ($this->appinfo->version) {
default:
// All versions of the app have had the same db structure, so all can use the same import function
$query = $this->content->prepare('SELECT * FROM `calendar_calendars` WHERE `userid` = ?');
$results = $query->execute(array($this->olduid));
$idmap = array();
while ($row = $results->fetchRow()) {
// Import each calendar
$calendarquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_calendars` (`userid`,`displayname`,`uri`,`ctag`,`calendarorder`,`calendarcolor`,`timezone`,`components`) VALUES(?,?,?,?,?,?,?,?)');
$calendarquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['ctag'], $row['calendarorder'], $row['calendarcolor'], $row['timezone'], $row['components']));
// Map the id
$idmap[$row['id']] = OCP\DB::insertid('*PREFIX*calendar_calendars');
// Make the calendar active
OC_Calendar_Calendar::setCalendarActive($idmap[$row['id']], true);
}
// Now tags
foreach ($idmap as $oldid => $newid) {
$query = $this->content->prepare('SELECT * FROM `calendar_objects` WHERE `calendarid` = ?');
$results = $query->execute(array($oldid));
while ($row = $results->fetchRow()) {
// Import the objects
$objectquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_objects` (`calendarid`,`objecttype`,`startdate`,`enddate`,`repeating`,`summary`,`calendardata`,`uri`,`lastmodified`) VALUES(?,?,?,?,?,?,?,?,?)');
$objectquery->execute(array($newid, $row['objecttype'], $row['startdate'], $row['enddate'], $row['repeating'], $row['summary'], $row['calendardata'], $row['uri'], $row['lastmodified']));
}
}
// All done!
break;
}
return true;
}
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:32,代码来源:migrate.php
示例3: getTasks
/**
* @NoAdminRequired
*/
public function getTasks()
{
$calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
$user_timezone = \OC_Calendar_App::getTimezone();
$tasks = array();
foreach ($calendars as $calendar) {
$calendar_tasks = \OC_Calendar_Object::all($calendar['id']);
foreach ($calendar_tasks as $task) {
if ($task['objecttype'] != 'VTODO') {
continue;
}
if (is_null($task['summary'])) {
continue;
}
$vtodo = Helper::parseVTODO($task['calendardata']);
try {
$task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone);
$task_data['calendarid'] = $calendar['id'];
$task_data['calendarcolor'] = $calendar['calendarcolor'];
$tasks[] = $task_data;
} catch (\Exception $e) {
\OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
}
}
}
$result = array('data' => array('tasks' => $tasks));
$response = new JSONResponse();
$response->setData($result);
return $response;
}
开发者ID:msbt,项目名称:tasks,代码行数:33,代码来源:taskscontroller.php
示例4: search
/**
* Search for query in calendar events
*
* @param string $query
* @return array list of \OCA\Calendar\Search\Event
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('calendar')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
$objects = \OC_Calendar_Object::all($calendar['id']);
$date = strtotime($query);
// search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-events
if ($object['objecttype'] != 'VEVENT') {
continue;
}
// check the event summary string
if (stripos($object['summary'], $query) !== false) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
// check if the event is happening on a queried date
$range = $this->getDateRange($object);
if ($date && $this->fallsWithin($date, $range)) {
$results[] = new \OCA\Calendar\Search\Event($object);
continue;
}
}
}
return $results;
}
开发者ID:yheric455042,项目名称:owncloud82,代码行数:38,代码来源:provider.php
示例5: deleteUser
/**
* @brief Deletes all calendars of a certain user
* @param paramters parameters from postDeleteUser-Hook
* @return array
*/
public static function deleteUser($parameters)
{
$calendars = OC_Calendar_Calendar::allCalendars($parameters['uid']);
foreach ($calendars as $calendar) {
OC_Calendar_Calendar::deleteCalendar($calendar['id']);
}
return true;
}
开发者ID:blablubli,项目名称:owncloudapps,代码行数:13,代码来源:hooks.php
示例6: getCalendars
private function getCalendars()
{
$calendars = array();
foreach (OC_Calendar_Calendar::allCalendars($this->user, true) as $cal) {
$calendars[$cal['id']] = $cal['displayname'];
}
return $calendars;
}
开发者ID:kam1katze,项目名称:ocDashboard,代码行数:8,代码来源:tasks.php
示例7: calendar
/**
* @brief exports a calendar and convert all times to UTC
* @param integer $id id of the calendar
* @return string
*/
private static function calendar($id)
{
$events = OC_Calendar_Object::all($id);
$calendar = OC_Calendar_Calendar::find($id);
$return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\nX-WR-CALNAME:" . $calendar['displayname'] . "\n";
foreach ($events as $event) {
$return .= self::generateEvent($event);
}
$return .= "END:VCALENDAR";
return $return;
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:16,代码来源:export.php
示例8: generateTarget
/**
* @brief Get a unique name of the item for the specified user
* @param string Item
* @param string|false User the item is being shared with
* @param array|null List of similar item names already existing as shared items
* @return string Target name
*
* This function needs to verify that the user does not already have an item with this name.
* If it does generate a new name e.g. name_#
*/
public function generateTarget($itemSource, $shareWith, $exclude = null)
{
$calendar = OC_Calendar_App::getCalendar($itemSource);
$user_calendars = array();
foreach (OC_Calendar_Calendar::allCalendars($shareWith) as $user_calendar) {
$user_calendars[] = $user_calendar['displayname'];
}
$name = $calendar['userid'] . "'s " . $calendar['displayname'];
$suffix = '';
while (in_array($name . $suffix, $user_calendars)) {
$suffix++;
}
return $name . $suffix;
}
开发者ID:netcon-source,项目名称:apps,代码行数:24,代码来源:calendar.php
示例9: search
/**
* Search for query in tasks
*
* @param string $query
* @return array list of \OCA\Tasks\Controller\Task
*/
function search($query)
{
$calendars = \OC_Calendar_Calendar::allCalendars(\OC::$server->getUserSession()->getUser()->getUID(), true);
$user_timezone = \OC_Calendar_App::getTimezone();
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
// $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
$objects = \OC_Calendar_Object::all($calendar['id']);
// $date = strtotime($query);
// // search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-todos
if ($object['objecttype'] != 'VTODO') {
continue;
}
if (!($vtodo = Helper::parseVTODO($object))) {
continue;
}
$id = $object['id'];
$calendarId = $object['calendarid'];
// check these properties
$properties = array('SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES');
foreach ($properties as $property) {
$string = $vtodo->{$property};
if (stripos($string, $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
$comments = $vtodo->COMMENT;
if ($comments) {
foreach ($comments as $com) {
if (stripos($com->getValue(), $query) !== false) {
// $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query,$user_timezone);
$results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
continue 2;
}
}
}
}
}
usort($results, array($this, 'sort_completed'));
return $results;
}
开发者ID:sbambach,项目名称:tasks,代码行数:55,代码来源:searchcontroller.php
示例10: search
function search($query)
{
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
//return false;
}
$results = array();
$searchquery = array();
if (substr_count($query, ' ') > 0) {
$searchquery = explode(' ', $query);
} else {
$searchquery[] = $query;
}
$user_timezone = OC_Calendar_App::getTimezone();
$l = new OC_l10n('calendar');
foreach ($calendars as $calendar) {
$objects = OC_Calendar_Object::all($calendar['id']);
foreach ($objects as $object) {
if ($object['objecttype'] != 'VEVENT') {
continue;
}
if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
$calendardata = OC_VObject::parse($object['calendardata']);
$vevent = $calendardata->VEVENT;
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
$start_dt = $dtstart->getDateTime();
$start_dt->setTimezone(new DateTimeZone($user_timezone));
$end_dt = $dtend->getDateTime();
$end_dt->setTimezone(new DateTimeZone($user_timezone));
if ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE) {
$end_dt->modify('-1 sec');
if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
} else {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
}
} else {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
$link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
$results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
//$name,$text,$link,$type
}
}
}
return $results;
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:48,代码来源:search.php
示例11: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
if ($uid != OCP\USER::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . OCP\USER::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . OCP\USER::getUser();
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:28,代码来源:calendar.php
示例12: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
if ($uid != OCP\USER::getUser()) {
$object = OC_VObject::parse($this->objectData['calendardata']);
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
$sharedAccessClassPermissions = OC_Calendar_App::getAccessClassPermissions($object->VEVENT->CLASS->value);
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ && $sharedAccessClassPermissions & OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . OCP\USER::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . OCP\USER::getUser();
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:30,代码来源:object.php
示例13: getACL
/**
* Returns a list of ACE's for this node.
*
* Each ACE has the following properties:
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
* currently the only supported privileges
* * 'principal', a url to the principal who owns the node
* * 'protected' (optional), indicating that this ACE is not allowed to
* be updated.
*
* @return array
*/
public function getACL()
{
$readprincipal = $this->getOwner();
$writeprincipal = $this->getOwner();
$uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
if ($uid != OCP\USER::getUser()) {
if ($uid === 'contact_birthdays') {
$readprincipal = 'principals/' . OCP\User::getUser();
} else {
$object = \Sabre\VObject\Reader::read($this->objectData['calendardata']);
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
$sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object);
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ && $sharedAccessClassPermissions & OCP\PERMISSION_READ) {
$readprincipal = 'principals/' . OCP\USER::getUser();
}
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & OCP\PERMISSION_UPDATE) {
$writeprincipal = 'principals/' . OCP\USER::getUser();
}
}
}
return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
}
开发者ID:rotdrop,项目名称:calendar,代码行数:34,代码来源:object.php
示例14:
<?php
/**
* Copyright (c) 2011 Bart Visscher <[email protected]>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$tmpl = new OCP\Template('calendar', 'settings');
$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', '');
$tmpl->assign('timezone', $timezone);
$tmpl->assign('timezones', DateTimeZone::listIdentifiers());
$tmpl->assign('calendars', OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()), false);
OCP\Util::addscript('calendar', 'settings');
$tmpl->printPage();
开发者ID:omusico,项目名称:isle-web-framework,代码行数:15,代码来源:settings.php
示例15: getowner
/**
* @brief returns the owner of an object
* @param integer $id
* @return string
*/
public static function getowner($id)
{
if ($id == 0) {
return null;
}
$event = self::find($id);
$cal = OC_Calendar_Calendar::find($event['calendarid']);
if ($cal === false || is_array($cal) === false) {
return null;
}
if (array_key_exists('userid', $cal)) {
return $cal['userid'];
} else {
return null;
}
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:21,代码来源:object.php
示例16: createCalendarName
public function createCalendarName()
{
$calendars = OC_Calendar_Calendar::allCalendars($this->userid);
$calendarname = $guessedcalendarname = !is_null($this->guessCalendarName()) ? $this->guessCalendarName() : OC_Calendar_App::$l10n->t('New Calendar');
$i = 1;
while (!OC_Calendar_Calendar::isCalendarNameavailable($calendarname, $this->userid)) {
$calendarname = $guessedcalendarname . ' (' . $i . ')';
$i++;
}
return $calendarname;
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:11,代码来源:import.php
示例17:
<?php
/**
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once '../../lib/base.php';
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if (count($calendars) == 0) {
OC_Calendar_Calendar::addCalendar(OC_User::getUser(), 'default', 'Default calendar');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
}
OC_UTIL::addScript('calendar', 'calendar');
OC_UTIL::addStyle('calendar', 'style');
OC_UTIL::addScript('', 'jquery.multiselect');
OC_UTIL::addStyle('', 'jquery.multiselect');
OC_APP::setActiveNavigationEntry('calendar_index');
$output = new OC_TEMPLATE('calendar', 'calendar', 'user');
$output->printPage();
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:24,代码来源:owncloud_apps_calendar_index.php
示例18: sendEmails
/**
* @brief use to create HTML emails and send them
* @param $eventid The event id
* @param $location The location
* @param $description The description
* @param $dtstart The start date
* @param $dtend The end date
*
*/
public static function sendEmails($eventid, $summary, $location, $description, $dtstart, $dtend)
{
$user = \OCP\User::getUser();
$eventsharees = array();
$eventShareesNames = array();
$emails = array();
$sharedwithByEvent = \OCP\Share::getItemShared('event', $eventid);
if (is_array($sharedwithByEvent)) {
foreach ($sharedwithByEvent as $share) {
if ($share['share_type'] === \OCP\Share::SHARE_TYPE_USER || $share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
$eventsharees[] = $share;
}
}
foreach ($eventsharees as $sharee) {
$shwth = $sharee['share_with'];
if ($sharee['share_type'] == \OCP\Share::SHARE_TYPE_GROUP) {
foreach (OC_Group::usersInGroup($shwth) as $u) {
if (!in_array($u, $eventShareesNames)) {
$eventShareesNames[] = $u;
}
}
} else {
if (!in_array($shwth, $eventShareesNames)) {
$eventShareesNames[] = $shwth;
}
}
}
}
foreach ($eventShareesNames as $name) {
$result = OC_Calendar_Calendar::getUsersEmails($name);
$emails[] = $result;
}
$adminmail = \OCP\Util::getDefaultEmailAddress('no-reply');
foreach ($emails as $email) {
if ($email === null) {
continue;
}
$subject = 'Calendar Event Shared';
$message = '<html><body>';
$message .= '<table style="border:1px solid black;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td colspan='2'><strong>" . $user . '</strong><strong> has shared with you an event</strong></td></tr>';
$message .= '<tr><td><strong>Summary:</strong> </td><td>' . \OCP\Util::sanitizeHTML($summary) . '</td></tr>';
$message .= '<tr><td><strong>Location:</strong> </td><td>' . \OCP\Util::sanitizeHTML($location) . '</td></tr>';
$message .= '<tr><td><strong>Description:</strong> </td><td>' . \OCP\Util::sanitizeHTML($description) . '</td></tr>';
$message .= '</table>';
$message .= '</body></html>';
OCP\Util::sendMail($email, \OCP\User::getDisplayName(), $subject, $message, $adminmail, $user, $html = 1);
}
}
开发者ID:yheric455042,项目名称:owncloud82,代码行数:58,代码来源:app.php
示例19: createProject
/**
* @brief Creates a new project
* @param Project title
* @param Description of the project
* @param Member who created the project
* @param Deadline of the project
* @param List of members working in the project and their roles
* @return int|boolean (Post ID of the post specifying the project creation|false)
*/
public static function createProject($title, $desc, $creator, $deadline, $details = NULL)
{
$post_id = NULL;
try {
\OCP\DB::beginTransaction();
$calendar_id = OC_Calendar_Calendar::addCalendar(\OC_User::getUser(), $title, 'VEVENT,VTODO,VJOURNAL', null, 0, '#3a87ad');
$query = \OCP\DB::prepare('INSERT INTO `*PREFIX*collaboration_project`(`title`, `description`, `starting_date`, `ending_date`, `last_updated`, `calendar_id`) VALUES(?, ?, CURRENT_TIMESTAMP, ?, CURRENT_TIMESTAMP, ?)');
$query->execute(array($title, $desc, OC_Collaboration_Time::convertUITimeToDBTime($deadline . ' 23:59:59'), $calendar_id));
$pid = OCP\DB::insertid('*PREFIX*collaboration_project');
$add_member = \OCP\DB::prepare('INSERT INTO `*PREFIX*collaboration_works_on`(`pid`, `member`, `role`) VALUES(?, ?, ?)');
$add_member->execute(array($pid, $creator, 'Creator'));
$cnt = count($details);
if ($cnt != 0 && isset($details[0]['member'])) {
foreach ($details as $detail) {
$member = strtolower($detail['member']);
if (!OC_User::userExists($member)) {
OC_User::createUser($member, $member);
}
$add_member->execute(array($pid, $member, $detail['role']));
OC_Preferences::setValue($member, 'settings', 'email', $detail['email']);
OC_Preferences::setValue($member, 'collaboration', 'mobile', $detail['mobile']);
}
}
$post_id = OC_Collaboration_Post::createPost('Project Created', 'Project \'' . $title . '\' has been created with deadline ' . OC_Collaboration_Time::convertToFullDate($deadline) . '.', $creator, $pid, 'Project Creation', array(), true);
\OCP\DB::commit();
} catch (\Exception $e) {
OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
return false;
}
return $post_id;
}
开发者ID:TheAgentK,项目名称:owncloud-collaboration,代码行数:40,代码来源:projects.php
示例20: setName
/**
* set name of list by id
*
* @param $id
* @param $name
* @return array
* @throws \Exception
*/
public function setName($id, $name)
{
if (trim($name) == '') {
// OCP\JSON::error(array('message'=>'empty'));
exit;
}
$calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
foreach ($calendars as $cal) {
if ($cal['userid'] != $this->userId) {
continue;
}
if ($cal['displayname'] == $name && $cal['id'] != $id) {
// OCP\JSON::error(array('message'=>'namenotavailable'));
exit;
}
}
$color = '#CCCCCC';
\OC_Calendar_Calendar::editCalendar($id, strip_tags($name), null, null, null, $color);
return array();
}
开发者ID:sbambach,项目名称:tasks,代码行数:28,代码来源:listsservice.php
注:本文中的OC_Calendar_Calendar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论