当前位置: 首页>>代码示例>>PHP>>正文


PHP Projects::findProjectIdsByUser方法代码示例

本文整理汇总了PHP中Projects::findProjectIdsByUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::findProjectIdsByUser方法的具体用法?PHP Projects::findProjectIdsByUser怎么用?PHP Projects::findProjectIdsByUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Projects的用法示例。


在下文中一共展示了Projects::findProjectIdsByUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findAll

 /**
  * Return all groups ordered by name
  * 
  * This function will return only groups visible to given user
  * 
  * If $return_all is set to true all groups will be loaded and returned. 
  * This is used in situations where we need all of them regardels of user 
  * previous assignments (like select project group helper)
  *
  * @param User $user
  * @param boolean $return_all
  * @return array
  */
 function findAll($user, $return_all = false)
 {
     if ($return_all || $user->isAdministrator() || $user->isProjectManager()) {
         return ProjectGroups::find(array('order' => 'name'));
     }
     // if
     $project_ids = Projects::findProjectIdsByUser($user);
     if (is_foreachable($project_ids)) {
         $projects_table = TABLE_PREFIX . 'projects';
         $project_groups_table = TABLE_PREFIX . 'project_groups';
         return ProjectGroups::findBySQL("SELECT DISTINCT {$project_groups_table}.* FROM {$projects_table}, {$project_groups_table} WHERE {$project_groups_table}.id = {$projects_table}.group_id AND {$projects_table}.id IN (?) ORDER BY {$project_groups_table}.name", array($project_ids));
     } else {
         return null;
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:29,代码来源:ProjectGroups.class.php

示例2: search


//.........这里部分代码省略.........
             $items = array();
             //$items = ProjectObjects::findBySQL("SELECT $project_objects_table.* FROM $project_objects_table, $search_index_table WHERE $type_filter AND MATCH ($search_index_table.content) AGAINST (? IN BOOLEAN MODE) AND $project_objects_table.id = $search_index_table.object_id AND $search_index_table.type = ? AND state >= ? AND visibility >= ? LIMIT $offset, $per_page", array($search_for, $type, STATE_VISIBLE, $user->getVisibility()));
             $ids = array();
             //BOF:mod 20110706 ticketid222
             /*
             //EOF:mod 20110706 ticketid222
             $query = $query_main . " order by 2, 1 LIMIT " . $offset . " ," . $per_page;
             //BOF:mod 20110706 ticketid222
             */
             //BOF:mod 20120711
             if (empty($datesort)) {
                 //EOF:mod 20120711
                 $query = $query_main . " order by new_order ASC, 2, 1, created_on desc LIMIT " . $offset . " ," . $per_page;
                 //BOF:mod 20120711
             } elseif ($datesort == 'a') {
                 $query = $query_main . " order by created_on, new_order ASC, 2, 1 LIMIT " . $offset . " ," . $per_page;
             } elseif ($datesort == 'd') {
                 $query = $query_main . " order by created_on desc, new_order ASC, 2, 1 LIMIT " . $offset . " ," . $per_page;
             }
             //EOF:mod 20120711
             //EOF:mod 20110706 ticketid222
             $result = mysql_query($query, $link);
             while ($info = mysql_fetch_assoc($result)) {
                 $ids[] = $info['id'];
                 $rows[] = $info;
             }
             foreach ($rows as $row) {
                 $item_class = array_var($row, 'type');
                 $item = new $item_class();
                 $item->loadFromRow($row);
                 $add_item = true;
                 if ($_GET['complete'] != '1') {
                     if ($item->getParentType() == 'Page') {
                         $temp_page = new Page($item->getParentId());
                         $is_archived = $temp_page->getIsArchived();
                         if ($is_archived) {
                             $add_item = false;
                         }
                     }
                     if ($add_item) {
                         $temp_obj = new ProjectObject($item->getParentId());
                         if ($temp_obj->isCompleted()) {
                             $add_item = false;
                         }
                     }
                 }
                 if ($add_item) {
                     $items[] = $item;
                 }
             }
             if (empty($search_object_type)) {
                 //$items = ProjectObjects::findBySQL("SELECT $project_objects_table.* FROM $project_objects_table, $search_index_table WHERE $type_filter AND MATCH ($search_index_table.content) AGAINST (? IN BOOLEAN MODE) AND $project_objects_table.id = $search_index_table.object_id AND $search_index_table.type = ? AND state >= ? AND visibility >= ? LIMIT $offset, $per_page", array($search_for, $type, STATE_VISIBLE, $user->getVisibility()));
             } else {
                 //$items = ProjectObjects::findBySQL("SELECT $project_objects_table.* FROM $project_objects_table, $search_index_table WHERE $type_filter AND MATCH ($search_index_table.content) AGAINST (? IN BOOLEAN MODE) AND $project_objects_table.id = $search_index_table.object_id AND $search_index_table.type = ? AND state >= ? AND visibility >= ? AND $project_objects_table.type = ? LIMIT $offset, $per_page", array($search_for, $type, STATE_VISIBLE, $user->getVisibility(), $search_object_type));
             }
             //mysql_query("insert into healingcrystals_testing (query, fired_at) values ('" . mysql_real_escape_string($query) . "', now())", $link);
         } else {
             $items = null;
         }
         // if
         mysql_close($link);
         return array($items, new Pager($page, $total_items, $per_page), $count);
         // Search for projects
     } elseif ($type == 'Project') {
         $project_ids = Projects::findProjectIdsByUser($user, null, true);
         if (!is_foreachable($project_ids)) {
             return array(null, new Pager(1, 0, $per_page));
         }
         // if
         $projects_table = TABLE_PREFIX . 'projects';
         $total_items = (int) array_var(db_execute_one("SELECT COUNT({$projects_table}.id) AS 'row_count' FROM {$projects_table}, {$search_index_table} WHERE {$projects_table}.id IN (?) AND MATCH ({$search_index_table}.content) AGAINST (? IN BOOLEAN MODE) AND {$projects_table}.id = {$search_index_table}.object_id AND {$search_index_table}.type = ?", $project_ids, $search_for, 'Project'), 'row_count');
         if ($total_items) {
             $items = Projects::findBySQL("SELECT * FROM {$projects_table}, {$search_index_table} WHERE {$projects_table}.id IN (?) AND MATCH ({$search_index_table}.content) AGAINST (? IN BOOLEAN MODE) AND {$projects_table}.id = {$search_index_table}.object_id AND {$search_index_table}.type = ? LIMIT {$offset}, {$per_page}", array($project_ids, $search_for, 'Project'));
         } else {
             $items = null;
         }
         // if
         return array($items, new Pager($page, $total_items, $per_page));
         // Search for users
     } elseif ($type == 'User') {
         $user_ids = $user->visibleUserIds();
         if (!is_foreachable($user_ids)) {
             return array(null, new Pager(1, 0, $per_page));
         }
         // if
         $users_table = TABLE_PREFIX . 'users';
         $total_items = (int) array_var(db_execute_one("SELECT COUNT({$users_table}.id) AS 'row_count' FROM {$users_table}, {$search_index_table} WHERE {$users_table}.id IN (?) AND MATCH ({$search_index_table}.content) AGAINST (? IN BOOLEAN MODE) AND {$users_table}.id = {$search_index_table}.object_id AND {$search_index_table}.type = ?", $user_ids, $search_for, 'User'), 'row_count');
         if ($total_items) {
             $items = Users::findBySQL("SELECT * FROM {$users_table}, {$search_index_table} WHERE {$users_table}.id IN (?) AND MATCH ({$search_index_table}.content) AGAINST (? IN BOOLEAN MODE) AND {$users_table}.id = {$search_index_table}.object_id AND {$search_index_table}.type = ? LIMIT {$offset}, {$per_page}", array($user_ids, $search_for, 'User'));
         } else {
             $items = null;
         }
         // if
         return array($items, new Pager($page, $total_items, $per_page));
         // Unknown search type
     } else {
         return array(null, new Pager(1, 0, $per_page));
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:MysqlSearchEngine.class.php

示例3: add_to_projects

 /**
  * Show and process add to projects page
  *
  * @param void
  * @return null
  */
 function add_to_projects()
 {
     if ($this->active_user->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->logged_user->isProjectManager()) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $add_to_projects_data = $this->request->post('add_to_projects');
     $this->smarty->assign(array('add_to_projects_data' => $add_to_projects_data, 'exclude_project_ids' => Projects::findProjectIdsByUser($this->active_user)));
     if ($this->request->isSubmitted()) {
         $errors = new ValidationErrors();
         $projects = null;
         if (is_foreachable($add_to_projects_data['projects'])) {
             $projects = Projects::findByIds($add_to_projects_data['projects']);
         }
         // if
         if (!is_foreachable($projects)) {
             $errors->addError(lang('Please select projects'), 'projects');
         }
         // if
         if ($add_to_projects_data['role_id']) {
             $role = Roles::findById($add_to_projects_data['role_id']);
             $permissions = null;
             if (!instance_of($role, 'Role') || !($role->getType() == ROLE_TYPE_PROJECT)) {
                 $errors->addError(lang('Invalid project role'), 'project_permissions');
             }
             // if
         } else {
             $role = null;
             $permissions = array_var($add_to_projects_data, 'permissions');
         }
         // if
         if ($errors->hasErrors()) {
             $this->smarty->assign('errors', $errors);
         } else {
             $added = 0;
             foreach ($projects as $project) {
                 $add = $project->addUser($this->active_user, $role, $permissions);
                 if ($add && !is_error($add)) {
                     $added++;
                 }
                 // if
             }
             // foreach
             if ($added == 1) {
                 flash_success(':name has been added to 1 project', array('name' => $this->active_user->getDisplayName()));
             } else {
                 flash_success(':name has been added to :count projects', array('name' => $this->active_user->getDisplayName(), 'count' => $added));
             }
             // if
             $this->redirectToUrl($this->active_user->getViewUrl());
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:65,代码来源:UsersController.class.php


注:本文中的Projects::findProjectIdsByUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。