Example #1
0
 public function findRecent($start = false, $limit = false)
 {
     $storeParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl();
     $joinSearchCacheCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('`t`.`id`', '`sc`.`model_id`')->addCondition('model_type_id', $this->modelTypeId(), '=', 'sc');
     $storeParams->join(\GO\Base\Model\SearchCacheRecord::model()->tableName(), $joinSearchCacheCriteria, 'sc', 'INNER');
     $aclJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('a.acl_id', 'sc.acl_id', '=', false);
     $aclWhereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'a', false)->addInCondition("group_id", \GO\Base\Model\User::getGroupIds(\GO::user()->id), "a", false);
     $storeParams->join(\GO\Base\Model\AclUsersGroups::model()->tableName(), $aclJoinCriteria, 'a', 'INNER');
     $storeParams->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(Folder::model())->mergeWith($aclWhereCriteria));
     $storeParams->group(array('t.id'))->order('mtime', 'DESC');
     $storeParams->getCriteria()->addCondition('mtime', \GO\Base\Util\Date::date_add(\GO\Base\Util\Date::clear_time(time()), -7), '>');
     if ($start !== false) {
         $storeParams->start($start);
     }
     if ($limit !== false) {
         $storeParams->limit($limit);
     }
     return $this->find($storeParams);
 }
Example #2
0
 private function _searchFiles($params)
 {
     $response['success'] = true;
     $queryStr = !empty($params['query']) ? '%' . $params['query'] . '%' : '%';
     $limit = !empty($params['limit']) ? $params['limit'] : 30;
     $start = !empty($params['start']) ? $params['start'] : 0;
     $aclJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('a.acl_id', 'sc.acl_id', '=', false);
     $aclWhereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'a', false)->addInCondition("group_id", \GO\Base\Model\User::getGroupIds(\GO::user()->id), "a", false);
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('*')->ignoreAcl()->joinCustomFields()->joinModel(array('model' => 'GO\\Base\\Model\\SearchCacheRecord', 'localTableAlias' => 't', 'localField' => 'id', 'foreignField' => 'model_id', 'tableAlias' => 'sc'))->join(\GO\Base\Model\AclUsersGroups::model()->tableName(), $aclJoinCriteria, 'a', 'INNER')->debugSql()->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('model_type_id', \GO::getModel('GO\\Files\\Model\\File')->modelTypeId(), '=', 'sc', true)->mergeWith(\GO\Base\Db\FindCriteria::newInstance()->addCondition('name', $queryStr, 'LIKE', 'sc', false)->addCondition('keywords', $queryStr, 'LIKE', 'sc', false))->mergeWith($aclWhereCriteria));
     $filesStmt = \GO\Files\Model\File::model()->find($findParams);
     $response['total'] = $filesStmt->rowCount();
     $filesStmt = \GO\Files\Model\File::model()->find($findParams->start($start)->limit($limit));
     $response['results'] = array();
     $response['cm_state'] = '';
     $response['may_apply_state'] = false;
     $response['lock_state'] = false;
     $response['permission_level'] = 0;
     foreach ($filesStmt as $searchFileModel) {
         $response['results'][] = $searchFileModel->getJsonData();
     }
     return $response;
 }
Example #3
0
 /**
  * Get all the subfolders of this folder. This function checks permissions in a
  * special way. When folder have acl_id=0 they inherit permissions of the parent folder.
  *
  * @return \GO\Base\Db\ActiveStatement
  */
 public function getSubFolders($findParams = false, $noGrouping = false)
 {
     if (!$findParams) {
         $findParams = \GO\Base\Db\FindParams::newInstance();
     }
     $findParams->ignoreAcl();
     //We'll build a special acl check for folders that inherit permissions here.
     //$findParams->debugSql();
     $aclJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('a.acl_id', 't.acl_id', '=', false);
     $aclWhereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('acl_id', 0, '=', 't', false)->addCondition('user_id', \GO::user()->id, '=', 'a', false)->addInCondition("group_id", \GO\Base\Model\User::getGroupIds(\GO::user()->id), "a", false);
     $findParams->join(\GO\Base\Model\AclUsersGroups::model()->tableName(), $aclJoinCriteria, 'a', 'LEFT');
     $findParams->criteria(\GO\Base\Db\FindCriteria::newInstance()->addModel(Folder::model())->addCondition('parent_id', $this->id)->mergeWith($aclWhereCriteria));
     if (!$noGrouping) {
         $findParams->group(array('t.id'));
     }
     return Folder::model()->find($findParams);
 }
Example #4
0
 protected function afterDelete()
 {
     //delete all acl records
     $stmt = AclUsersGroups::model()->find(array("by" => array(array('user_id', $this->id))));
     while ($r = $stmt->fetch()) {
         $r->delete();
     }
     $defaultModels = AbstractUserDefaultModel::getAllUserDefaultModels();
     foreach ($defaultModels as $model) {
         $model->deleteByAttribute('user_id', $this->id);
     }
     //		deprecated. It's inefficient and can be done with listeners
     //		GO::modules()->callModuleMethod('deleteUser', array(&$this));
     return parent::afterDelete();
 }
Example #5
0
 /**
  * Get all user contacts that a given user is authorized to see
  * 
  * @param int $user_id
  * @param \GO\Base\Db\FindParams $findParams
  * @return Contact Statement
  */
 public function findUsers($user_id, \GO\Base\Db\FindParams $findParams = null)
 {
     $aclJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addRawCondition('a.acl_id', 'goUser.acl_id', '=', false);
     $aclWhereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', $user_id, '=', 'a', false)->addInCondition("group_id", \GO\Base\Model\User::getGroupIds($user_id), "a", false);
     $fp = \GO\Base\Db\FindParams::newInstance()->group('t.id')->ignoreAcl()->joinRelation('goUser')->join(\GO\Base\Model\AclUsersGroups::model()->tableName(), $aclJoinCriteria, 'a', 'INNER');
     $fp->getCriteria()->addCondition('enabled', true, '=', 'goUser')->mergeWith($aclWhereCriteria);
     if (isset($findParams)) {
         $fp->mergeWith($findParams);
     }
     return Contact::model()->find($fp);
 }