Пример #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;
 }
    /**
     * @brief Provides details for generating the project timeline
     * @param Project ID
     */
    public static function getProjectStatus($pid)
    {
        try {
            $query = OCP\DB::prepare('SELECT `finished`.`count` AS finished, `pending`.`count` AS pending, 
									 `starting_date`, `ending_date`, now() as now, `completed`, `last_updated` 
									 FROM (SELECT COUNT(`status`) AS count
									  	  FROM `*PREFIX*collaboration_task_status` AS tstatus 
									  	  JOIN `*PREFIX*collaboration_task` AS task 
									  	  ON (`tstatus`.`tid`=`task`.`tid`) 
									  	  WHERE `task`.`pid`=? 
										  AND `last_updated_time`=
										  		(SELECT MAX(`last_updated_time`) 
										  		FROM `*PREFIX*collaboration_task_status` 
										  		WHERE `tid`=`tstatus`.`tid`) 
										  AND `status`=\'Verified\') AS finished,
										  (SELECT COUNT(`status`) AS count
									  	  FROM `*PREFIX*collaboration_task_status` AS tstatus 
									  	  JOIN `*PREFIX*collaboration_task` AS task 
									  	  ON (`tstatus`.`tid`=`task`.`tid`) 
									  	  WHERE `task`.`pid`=? 
										  AND `last_updated_time`=
										  		(SELECT MAX(`last_updated_time`) 
										  		FROM `*PREFIX*collaboration_task_status` 
										  		WHERE `tid`=`tstatus`.`tid`) 
										  AND `status`<>\'Verified\'
										  AND `status`<>\'Cancelled\') AS pending,
										  `*PREFIX*collaboration_project`
									WHERE `pid`=?');
            $result = $query->execute(array($pid, $pid, $pid));
            $details = array();
            if ($row = $result->fetchRow()) {
                $details['progress'] = self::findProgress($row['starting_date'], $row['ending_date'], $row['now'], $row['completed']);
                $details['start_date'] = OC_Collaboration_Time::convertDBTimeToUITime($row['starting_date']);
                $details['deadline'] = OC_Collaboration_Time::convertDBTimeToUITime($row['ending_date']);
                $details['updated_time'] = OC_Collaboration_Time::convertDBTimeToUITime($row['last_updated']);
                $details['now'] = OC_Collaboration_Time::convertDBTimeToUITime($row['now']);
                $details['completed'] = $row['completed'];
                $details['num_completed_tasks'] = $row['finished'];
                $details['num_pending_tasks'] = $row['pending'];
            }
            return $details;
        } catch (\Exception $e) {
            OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
            return false;
        }
    }
    }
    ?>
					</td>
				</tr>

				<tr>
					<td>
						<?php 
    p($l->t('Deadline'));
    ?>
						<span class="required">*</span>
					</td>
					<td>
						<input type="text" id="deadline_time" name="deadline_time" placeholder="MM/DD/YYYY HH:MM" autocomplete="off" required <?php 
    if (isset($_['tid'])) {
        print_unescaped('value="' . OC_Collaboration_Time::convertDBTimeToUITimeShort($_['task_details']['ending_time']) . '"');
    }
    ?>
 />
					</td>
				</tr>
			</table>

			  <div id="submit-form" >
				  <input type="submit" value="<?php 
    p($_['submit_btn_name']);
    ?>
" />
			  </div>
	    </form>
	  <?php 
				</td>
			</tr>
			-->

			<tr>
				<td>
					<?php 
p($l->t('Deadline'));
?>
 : <span class="required">*</span>
				</td>

				<td>
					<input type="text" id="deadline" name="deadline" placeholder="MM/DD/YYYY" <?php 
if ($pid != -1) {
    print_unescaped('value="' . OC_Collaboration_Time::convertDBTimeToUIDate($_['project_details']['ending_date']) . '"');
}
?>
 autocomplete="off" required/>
					<?php 
if ($pid != -1) {
    ?>
					<label for="project_completed" ><?php 
    p($l->t('Completed?'));
    ?>
</label>
					<input type="checkbox" name="project_completed" id="project_completed" <?php 
    if ($_['project_details']['completed'] == true) {
        p('checked="checked"');
    }
    ?>
" />
    </form>
   <?php 
if (strcmp($_['permission_granted'], 'true') == 0) {
    $event_id = OC_Collaboration_Calendar::getEventId($_POST['tid']);
    if (!isset($_POST['status'])) {
        $_POST['member'] = "";
    }
    if (isset($_POST['status']) && strcasecmp($_POST['status'], 'Cancelled') == 0) {
        OC_Calendar_Object::delete($event_id);
    } else {
        $start = new DateTime(OC_Collaboration_Calendar::getEventStartTime($event_id));
        $start->setTimezone(new DateTimeZone('Asia/Kolkata'));
        $start_date = $start->format('d-m-Y');
        $start_time = $start->format('H:i:s');
        $deadline = new DateTime(OC_Collaboration_Time::convertUITimeShortToDBTimeShort($_POST['deadline_time']));
        $deadline_date = $deadline->format('d-m-Y');
        $deadline_time = $deadline->format('H:i:s');
        $last_modified = new DateTime();
        ?>
	 <form id="ev_form" action="" method="post" >
			<input type="hidden" name="create_new" value="false" id="create_new" />
			<input type="hidden" name="id" value="<?php 
        p($event_id);
        ?>
" />
			<input type="hidden" name="lastmodified" value="" />
			<input type="hidden" name="title" value="<?php 
        p($_POST['title']);
        ?>
" />
</th>
			 <th><?php 
p($l->t('Time'));
?>
</th>
			 <th><?php 
p($l->t('Comment'));
?>
</th>
		</tr>
		<?php 
for ($i = 0; $i < count($_['status_details']); $i++) {
    print_unescaped('
				<tr>
				  <td>' . OC_Collaboration_Task::getStatusInFormat($_['status_details'][$i]['status'], $_['status_details'][$i]['member'], $_['task_details']['creator']) . '</td>
				  <td>' . OC_Collaboration_Time::convertDBTimeToUITime($_['status_details'][$i]['time']) . '</td><td>' . $_['status_details'][$i]['comment'] . '</td>
				</tr>');
}
?>
	 </table>

	 <?php 
if (strcasecmp(OC_Collaboration_Task::getTaskCreator($_['task_details']['tid']), OC_User::getUser()) == 0) {
    ?>
		 <form action="<?php 
    print_unescaped(OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'update_task')));
    ?>
" method="post" >
			 <input type="hidden" name="tid" value="<?php 
    p($_['task_details']['tid']);
    ?>
OCP\JSON::checkAppEnabled('collaboration');
$l = new OC_l10n('collaboration');
if (isset($_POST['start']) && isset($_POST['count']) && isset($_POST['project']) && isset($_POST['status']) && isset($_POST['assigned_to']) && isset($_POST['assigned_by'])) {
    if ($_POST['project'] != '' && !OC_Collaboration_Project::isMemberWorkingOnProjectByTitle(OC_User::getUser(), $_POST['project'])) {
        throw new Exception(OC_User::getUser() . ' is trying to access project ' . $_POST['project']);
        OC_JSON::error();
        exit;
    }
    $args = array('assigned_to' => $_POST['assigned_to'] == true ? OC_User::getUser() : NULL, 'assigned_by' => $_POST['assigned_by'] == true ? OC_User::getUser() : NULL, 'project' => $_POST['project'] == '' ? NULL : $_POST['project'], 'status' => $_POST['status'] == '' ? NULL : $_POST['status']);
    $tasks = OC_Collaboration_Task::readTasks($args, $_POST['start'], $_POST['count']);
    $text = '';
    foreach ($tasks as $each) {
        if (!isset($each['tid']) || $each['tid'] == '') {
            break;
        }
        $datetime = OC_Collaboration_Time::convertDBTimeToUITime($each['ending_time']);
        $text .= '<div class="unit">
					<div class="task_title">' . $each['title'] . '</div>

					<div class="contents">	
						<div class="description">' . $each['description'] . '</div>							
							<br />
							<form class="view_details" action="' . \OCP\Util::linkToRoute('collaboration_route', array('rel_path' => 'task_details')) . '" method="post" >
								<input type="hidden" name="tid" value="' . $each['tid'] . '" />
								<input type="submit" value="' . $l->t('View details') . '" />
						</form>' . (strcasecmp(OC_Collaboration_Task::getTaskCreator($each['tid']), OC_User::getUser()) == 0 ? '<div class="edit" >
							<button class="btn_edit" id="btn_edit_' . $each['tid'] . '" >' . $l->t('Edit') . '</button>
							</div>' : '') . '</div>

					<div class="details">
						<div class="task_status">' . $l->t('Status: %s', array(OC_Collaboration_Task::getStatusInFormat($each['status'], $each['member'], $each['creator']))) . '</div>
		<tr>
			<td>
				<?php 
p($l->t('Status'));
?>
			</td>

			<td>
				:
			</td>

			<td id="project_status" >
				<?php 
if ($_['project_details']['completed'] == true) {
    p($l->t('Completed on %s', array($l->l('date', OC_Collaboration_Time::convertDBTimeToUIDate($_['project_details']['last_updated'])))));
    if (isset($_['msg'])) {
        print_unescaped('<span id="message" > (' . $_['msg'] . ')</span>');
    }
} else {
    p($l->t('In progress'));
}
?>
			</td>
		</tr>

		<tr>
			<td>
				<?php 
p($l->t('Members'));
?>
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
print_unescaped($this->inc('tabs'));
print_unescaped('<div id="collaboration_content">');
if (strcmp($_['permission_granted'], 'true') == 0) {
    if (!isset($_POST['status'])) {
        $_POST['member'] = "";
    }
    $today = new DateTime();
    $today->setTimezone(new DateTimeZone('Asia/Kolkata'));
    $today_date = $today->format('Y-m-d');
    $today_time = $today->format('H:i:s');
    $deadline = explode(' ', OC_Collaboration_Time::convertUITimeShortToDBTimeShort($_POST['deadline_time']));
    $deadline_date = $deadline[0];
    $deadline_time = $deadline[1];
    ?>
		<input type="hidden" name="create_new" value="true" id="create_new" />

		<form id="ev_form" action="" method="post" style="display: none;" >
			<input type="hidden" name="title" value="<?php 
    p($_POST['title']);
    ?>
" />
			<input type="hidden" name="categories" value="Projects" />
			<input type="hidden" name="calendar" value="<?php 
    p(OC_Collaboration_Calendar::getCalendarId($_POST['pid']));
    ?>
" />
Пример #10
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;
 }