Ejemplo n.º 1
0
 /**
 * Return array of task that are assigned to specific user or his company
 *
 * @param User $user
 * @return array
 */
 function getUsersTickets(User $user) {
   if (!plugin_active('tickets')) return null;
   $conditions = DB::prepareString('`project_id` = ? AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR `created_by_id`= ?) AND `closed_on` = ?', array($this->getId(), $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, $user->getId(), EMPTY_DATETIME));
   if(!$user->isMemberOfOwnerCompany()) {
     $conditions .= DB::prepareString(' AND `is_private` = ?', array(0));
   } // if
   return ProjectTickets::findAll(array(
     'conditions' => $conditions,
     'order' => '`created_on`'
   )); // findAll
 } // getUsersTickets
 /**
  * Return all tickets related to this message
  *
  * @access public
  * @param void
  * @return array
  */
 function getTickets()
 {
     if (!plugin_active('tickets')) {
         return array();
     }
     return ProjectTickets::findAll(array('conditions' => '`milestone_id` = ' . DB::escape($this->getId()), 'order' => 'created_on'));
     // findAll
 }
Ejemplo n.º 3
0
 /**
  * Return array of task that are assigned to specific user or his company
  *
  * @param User $user
  * @param array $options
  * @param boolean $include_company
  * @return array
  */
 function getUsersTickets(User $user, $options = null, $include_company = false)
 {
     if (!plugin_active('tickets')) {
         return null;
     }
     if ($include_company) {
         $conditions = DB::prepareString('`project_id` = ? AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR `created_by_id`= ?) AND `closed_on` = ?', array($this->getId(), $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, $user->getId(), EMPTY_DATETIME));
     } else {
         $conditions = DB::prepareString('`project_id` = ? AND `assigned_to_user_id` = ? AND `closed_on` = ?', array($this->getId(), $user->getId(), EMPTY_DATETIME));
     }
     // if
     if (!$user->isMemberOfOwnerCompany()) {
         $conditions .= DB::prepareString(' AND `is_private` = ?', array(0));
     }
     // if
     $options['conditions'] = $conditions;
     if (!isset($options['order'])) {
         $options['order'] = '`created_on`';
     }
     return ProjectTickets::findAll($options);
     // findAll
 }