Esempio n. 1
0
 /**
  * Find all shared folders for the current user
  * 
  * @param \GO\Base\Db\FindParams $findParams
  * @return \GO\Base\Db\ActiveStatement
  */
 private function _findShares($user_id)
 {
     $findParams = new \GO\Base\Db\FindParams();
     $findParams->getCriteria()->addModel(Folder::model())->addCondition('visible', 1);
     //						->addCondition('user_id', $user_id, '!=');
     return Folder::model()->find($findParams);
 }
Esempio n. 2
0
 protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
 {
     if (empty($params['forContextMenu'])) {
         $multiSel = new \GO\Base\Component\MultiSelectGrid('addresslist_filter', "GO\\Addressbook\\Model\\Addresslist", $store, $params, false);
         $multiSel->formatCheckedColumn();
     }
     $storeParams->getCriteria()->addCondition('level', $params['permissionLevel'], '>=', 'go_acl');
 }
Esempio n. 3
0
 /**
  * FIXME: this method was copied from ModelController and never tested
  * @param array $advancedQueryData the query data to be set to the store
  * @param array $storeParams store params to be modied by advancedQuery
  */
 private function _handleAdvancedQuery($advancedQueryData)
 {
     $advancedQueryData = is_string($advancedQueryData) ? json_decode($advancedQueryData, true) : $advancedQueryData;
     $findCriteria = $this->_extraFindParams->getCriteria();
     $criteriaGroup = \GO\Base\Db\FindCriteria::newInstance();
     $criteriaGroupAnd = true;
     for ($i = 0, $count = count($advancedQueryData); $i < $count; $i++) {
         $advQueryRecord = $advancedQueryData[$i];
         //change * into % wildcard
         $advQueryRecord['value'] = isset($advQueryRecord['value']) ? str_replace('*', '%', $advQueryRecord['value']) : '';
         if ($i == 0 || $advQueryRecord['start_group']) {
             $findCriteria->mergeWith($criteriaGroup, $criteriaGroupAnd);
             $criteriaGroupAnd = $advQueryRecord['andor'] == 'AND';
             $criteriaGroup = \GO\Base\Db\FindCriteria::newInstance();
         }
         if (!empty($advQueryRecord['field'])) {
             // Give the record a unique id, to enable the programmers to
             // discriminate between advanced search query records of the same field
             // type.
             $advQueryRecord['id'] = $i;
             // Check if current adv. search record should be handled in the standard
             // manner.
             $fieldParts = explode('.', $advQueryRecord['field']);
             if (count($fieldParts) == 2) {
                 $field = $fieldParts[1];
                 $tableAlias = $fieldParts[0];
             } else {
                 $field = $fieldParts[0];
                 $tableAlias = false;
             }
             if ($tableAlias == 't') {
                 $advQueryRecord['value'] = \GO::getModel($this->_modelClass)->formatInput($field, $advQueryRecord['value']);
             } elseif ($tableAlias == 'cf') {
                 $advQueryRecord['value'] = \GO::getModel(\GO::getModel($this->_modelClass)->customfieldsModel())->formatInput($field, $advQueryRecord['value']);
             }
             $criteriaGroup->addCondition($field, $advQueryRecord['value'], $advQueryRecord['comparator'], $tableAlias, $advQueryRecord['andor'] == 'AND');
         }
     }
     $findCriteria->mergeWith($criteriaGroup, $criteriaGroupAnd);
 }
Esempio n. 4
0
 protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
 {
     //SELECT * FROM cal_categories t
     //LEFT JOIN go_acl ON (`t`.`acl_id` = go_acl.acl_id AND (go_acl.user_id=57 OR go_acl.group_id IN (2)))
     //WHERE t.calendar_id = 0 AND go_acl.acl_id IS NOT NULL OR t.calendar_id=56
     $groupIds = \GO\Base\Model\User::getGroupIds(\GO::user()->id);
     $storeCriteria = $storeParams->getCriteria();
     $joinUserGroupCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'go_acl', false)->addInCondition('group_id', $groupIds, 'go_acl', false);
     $joinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('acl_id', 'go_acl.acl_id', '=', 't', true, true)->mergeWith($joinUserGroupCriteria);
     $storeParams->join('go_acl', $joinCriteria, 'go_acl', 'LEFT');
     if (!empty($params['global_categories']) && !empty($params['calendar_id'])) {
         $storeCriteria->addCondition('calendar_id', 0, '=', 't', false);
         $storeCriteria->addCondition('acl_id', NULL, 'IS NOT', 'go_acl');
         $storeCriteria->addCondition('calendar_id', $params['calendar_id'], '=', 't', false);
     } elseif (!empty($params['calendar_id'])) {
         $storeCriteria->addCondition('calendar_id', $params['calendar_id']);
     } else {
         $storeCriteria->addCondition('calendar_id', 0);
     }
     $storeParams->ignoreAcl();
     return parent::beforeStoreStatement($response, $params, $store, $storeParams);
 }
Esempio n. 5
0
 /**
  * Add the selected id's to the findCriteria. You use this in the other controller. eg. ContactController and not AddressbookController.
  * Should be called in \GO\Base\Controller\AbstractModelController::beforeStoreStatement
  * Will be called in \GO\Base\Data\DbStore::multiSelect()
  * @param \GO\Base\Db\FindParams $findParams (object reference)
  * @param string $columnName database column to match keys to
  * @param string $tableAlias table alias of the column to match
  * @param boolean $useAnd use AND when adding where condition
  * @param boolean $useNot use NOT when adding where condition
  */
 public function addSelectedToFindCriteria(\GO\Base\Db\FindParams &$findParams, $columnName, $tableAlias = 't', $useAnd = true, $useNot = false)
 {
     $selectedCount = count($this->selectedIds);
     //ignore here. Permissions are checked in by _setSelectedIds.
     if ($this->_checkPermissions) {
         //			$this->_validateSelection();
         if ($selectedCount) {
             $findParams->ignoreAcl();
         }
     }
     if ($selectedCount) {
         if ($selectedCount > 1) {
             $tableName = "ms_" . $this->_requestParamName;
             $findParams->getCriteria()->addInTemporaryTableCondition($tableName, $columnName, $this->selectedIds, $tableAlias, $useAnd, $useNot);
         } else {
             //				$findParams->getCriteria()->addInCondition($columnName, $this->selectedIds, $tableAlias, $useAnd, $useNot);
             $findParams->getCriteria()->addCondition($columnName, $this->selectedIds[0], $useNot ? '!=' : '=', $tableAlias, $useAnd);
         }
     }
     //		$findParams->debugSql();
     //		$this->_save();
 }
Esempio n. 6
0
 private function checkFilterParams($show, \GO\Base\Db\FindParams $params)
 {
     // Check for a given filter on the statusses
     if (!empty($show)) {
         $statusCriteria = $params->getCriteria();
         switch ($show) {
             case 'today':
                 $start_time = mktime(0, 0, 0);
                 $end_time = \GO\Base\Util\Date::date_add($start_time, 1);
                 break;
             case 'sevendays':
                 $start_time = mktime(0, 0, 0);
                 $end_time = \GO\Base\Util\Date::date_add($start_time, 7);
                 $show_completed = false;
                 break;
             case 'overdue':
                 $start_time = 0;
                 $end_time = mktime(0, 0, 0);
                 $show_completed = false;
                 $show_future = false;
                 break;
             case 'completed':
                 $start_time = 0;
                 $end_time = 0;
                 $show_completed = true;
                 //$show_future=false;
                 break;
             case 'future':
                 $start_time = 0;
                 $end_time = 0;
                 $show_completed = false;
                 $show_future = true;
                 break;
             case 'incomplete':
                 $start_time = 0;
                 $end_time = 0;
                 $show_completed = false;
                 break;
             case 'active':
             case 'portlet':
                 $start_time = 0;
                 $end_time = 0;
                 $show_completed = false;
                 $show_future = false;
                 break;
             default:
                 // Nothing
                 break;
         }
         if (isset($show_completed)) {
             if ($show_completed) {
                 $statusCriteria->addCondition('completion_time', 0, '>');
             } else {
                 $statusCriteria->addCondition('completion_time', 0, '=');
             }
         }
         if (!empty($start_time)) {
             $statusCriteria->addCondition('due_time', $start_time, '>=');
         }
         if (!empty($end_time)) {
             $statusCriteria->addCondition('due_time', $end_time, '<');
         }
         if (isset($show_future)) {
             $now = \GO\Base\Util\Date::date_add(mktime(0, 0, 0), 1);
             if ($show_future) {
                 $statusCriteria->addCondition('start_time', $now, '>=');
             } else {
                 $statusCriteria->addCondition('start_time', $now, '<');
             }
         }
         //$params->getCriteria()->mergeWith($statusCriteria);
         //			$params['criteriaObject']=$statusCriteria;
     }
     //		// Check for a given filter on the categories
     //		if(isset($params['categoryFilter'])) {
     //			$categoryCriteria = \GO\Base\Db\FindCriteria::newInstance()
     //				->addModel(\GO\Tasks\Model\Task::model(),'t');
     //
     //			$categories = json_decode($params['categoryFilter'], true);
     //
     ////			foreach($categories as $category)
     ////				$categoryCriteria->addCondition('category_id', $category, '=','t',false);
     //			//if(count($categories))
     //			$categoryCriteria->addInCondition('category_id', $categories,'t',false,false);
     //
     //			if(isset($params['criteriaObject']))
     //				$params['criteriaObject']->mergeWith($categoryCriteria);
     //			else
     //				$params['criteriaObject'] = $categoryCriteria;
     //		}
     return $params;
 }
Esempio n. 7
0
 /**
  *
  * @param \GO\Base\Db\FindParams $findParams
  * @return \GO\Base\Db\ActiveStatement
  */
 public function getTopLevelShares($findParams = false)
 {
     if (!$findParams) {
         $findParams = new \GO\Base\Db\FindParams();
     }
     $findParams->joinRelation('sharedRootFolders')->ignoreAcl()->order('name', 'ASC')->limit(200);
     $findParams->getCriteria()->addCondition('user_id', \GO::user()->id, '=', 'sharedRootFolders');
     return $this->find($findParams);
 }
Esempio n. 8
0
 protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
 {
     $storeParams->getCriteria()->addCondition('user_id', \GO::user()->id);
     return parent::beforeStoreStatement($response, $params, $store, $storeParams);
 }