Пример #1
0
 /**
  * @brief Modifies the given project
  * @param Project ID
  * @param Project title
  * @param Description of the project
  * @param Deadline of the project
  * @param List of members working in the project and their roles
  * @param Member who updated the project
  * @param Whether or not the project has been completed
  * @return int|boolean (Post ID of the post specifying the project updation|false)
  */
 public static function updateProject($pid, $title, $desc, $deadline, $details, $updater, $completed)
 {
     $post_id = NULL;
     try {
         if ($completed && OC_Collaboration_Task::hasPendingTasks($pid)) {
             throw new \Exception('Cannot delete project with pending tasks');
         }
         \OCP\DB::beginTransaction();
         $query = \OCP\DB::prepare('UPDATE `*PREFIX*collaboration_project` SET `title`=?, `description`=?, `last_updated`=CURRENT_TIMESTAMP, `ending_date`=?, `completed`=? WHERE `pid`=?');
         $query->execute(array($title, $desc, OC_Collaboration_Time::convertUITimeToDBTime($deadline . ' 23:59:59'), $completed, $pid));
         $add_member = \OCP\DB::prepare('INSERT INTO `*PREFIX*collaboration_works_on`(`pid`, `member`, `role`) VALUES(?, ?, ?)');
         $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 Updated', 'Project \'' . $title . '\' has been updated' . '.', $updater, $pid, 'Project Updation', array(), true);
         \OCP\DB::commit();
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
     return $post_id;
 }
Пример #2
0
 /**
  * @brief Modifies the given task with the given title and contents
  * @param Title of the task
  * @param Description of the task
  * @param Member who created the task
  * @param Project to which the task corresponds
  * @param Priority of the task
  * @param Task deadline
  * @param Task status
  * @param Member to whom the task is assigned
  * @param Reason for changing the task status
  * @return int|boolean (Task ID|false)
  */
 public static function updateTask($tid, $title, $desc, $creator, $pid, $priority, $end_time, $status, $member = NULL, $reason = NULL)
 {
     $deadline = explode(' ', $end_time);
     try {
         \OCP\DB::beginTransaction();
         $end_date = OC_Collaboration_Time::convertUITimeToDBTime($end_time . ':00');
         $query = OCP\DB::prepare('UPDATE `*PREFIX*collaboration_task` SET `title`=?, `description`=?, `priority`=?, `ending_time`=? WHERE `tid`=?');
         $result = $query->execute(array($title, $desc, $priority, $end_date, $tid));
         if (isset($status) && !is_null($status)) {
             self::changeStatus($tid, $title, $status, $creator, $member, $reason, true);
         }
         if (!is_null($member)) {
             OC_Collaboration_Post::createPost('Task Assigned', 'The task \'' . $title . '\' has been assigned with deadline ' . OC_Collaboration_Time::convertToFullDate($deadline[0]) . '.', $creator, $pid, 'Task Assigned', array($member), true, $tid);
         }
         \OCP\DB::commit();
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
     return $tid;
 }