/** * Return array of finished projects * * @access public * @param void * @return array */ function getFinishedProjects() { if (is_null($this->finished_projects)) { $this->finished_projects = ProjectUsers::getProjectsByUser($this, '`completed_on` > ' . DB::escape(EMPTY_DATETIME)); } // if return $this->finished_projects; }
/** * Return array of finished projects * * @access public * @param void * @return array */ function getFinishedProjects() { if (is_null($this->finished_projects)) { $projects_table = Projects::instance()->getTableName(true); $this->finished_projects = ProjectUsers::getProjectsByUser($this, "$projects_table.`completed_on` > " . DB::escape(EMPTY_DATETIME)); } // if return $this->finished_projects; } // getFinishedProjects
function do_unclassify($main_email) { $conv_emails = MailContents::getMailsFromConversation($main_email); foreach ($conv_emails as $email) { try { DB::beginWork(); //only get workspaces with R&W permissions $all_workspaces = ProjectUsers::getProjectsByUser(logged_user()); $ws_ids = array(); foreach ($all_workspaces as $ws) { $has_ws_perm = logged_user()->hasProjectPermission($ws, ProjectUsers::CAN_WRITE_MAILS); $has_gr_perm = false; if (!$has_ws_perm) { $groups = logged_user()->getGroups(); foreach ($groups as $group) { $has_gr_perm = $group->getProjectPermission($ws, ProjectUsers::CAN_WRITE_MAILS); } } if ($has_ws_perm || $has_gr_perm) { $ws_ids[] = $ws->getId(); } } $ws_ids = implode(',', $ws_ids); // remove workspaces $email->removeFromWorkspaces($ws_ids); // unclassify attachments, remove all allowed ws, then if file has no ws -> delete it if ($email->getHasAttachments()) { MailUtilities::parseMail($email->getContent(), $decoded, $parsedEmail, $warnings); if (isset($parsedEmail['Attachments'])) { $files = ProjectFiles::findAll(array('conditions' => 'mail_id = ' . $email->getId())); foreach ($files as $file) { $file->removeFromWorkspaces($ws_ids); $current_wss = $file->getWorkspaces(); if (!is_array($current_wss) || count($current_wss) == 0) { $file->delete(); } } } } DB::commit(); return true; } catch (Exception $e) { DB::rollback(); return false; } } }