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


PHP CProject::overrideDatabase方法代码示例

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


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

示例1: getFileCountByFolder

 public function getFileCountByFolder($notUsed = null, $folder_id, $task_id, $project_id, $company_id, $allowed_companies)
 {
     // SQL text for count the total recs from the selected option
     $q = $this->_getQuery();
     $q->addTable('files');
     $q->addQuery('count(files.file_id)');
     $q->addJoin('projects', 'p', 'p.project_id = file_project');
     $q->addJoin('users', 'u', 'u.user_id = file_owner');
     $q->addJoin('tasks', 't', 't.task_id = file_task');
     $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
     $q->addWhere('file_folder = ' . (int) $folder_id);
     //TODO: apply permissions properly
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $deny1 = $project->getDeniedRecords($this->_AppUI->user_id);
     if (count($deny1) > 0) {
         $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
     }
     //TODO: apply permissions properly
     $task = new CTask();
     $task->overrideDatabase($this->_query);
     $deny2 = $task->getDeniedRecords($this->_AppUI->user_id);
     if (count($deny2) > 0) {
         $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
     }
     if ($project_id) {
         $q->addWhere('file_project = ' . (int) $project_id);
     }
     if ($task_id) {
         $q->addWhere('file_task = ' . (int) $task_id);
     }
     if ($company_id) {
         $q->innerJoin('companies', 'co', 'co.company_id = p.project_company');
         $q->addWhere('company_id = ' . (int) $company_id);
         $q->addWhere('company_id IN (' . $allowed_companies . ')');
     }
     $q->addGroup('file_folder_name');
     $q->addGroup('project_name');
     $q->addGroup('file_name');
     // counts total recs from selection
     return count($q->loadList());
 }
开发者ID:illuminate3,项目名称:web2project,代码行数:42,代码来源:folders.class.php

示例2: testDelete

 /**
  * Tests deletion of a project.
  */
 public function testDelete()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store();
     $this->assertTrue($result);
     $original_id = $this->obj->project_id;
     $result = $this->obj->delete();
     $item = new CProject();
     $item->overrideDatabase($this->mockDB);
     $this->mockDB->stageHash(array('project_name' => '', 'project_url' => ''));
     $item->load($original_id);
     $this->assertTrue(is_a($item, 'CProject'));
     $this->assertEquals('', $item->project_name);
     $this->assertEquals('', $item->project_url);
     /*
      * TODO: Not sure on how to test the cascading deletes. They're handled
      *   in PHP, not in the database, so we need some assurance that they
      *   actually happen..
      */
 }
开发者ID:illuminate3,项目名称:web2project,代码行数:23,代码来源:CProjectsTest.php

示例3: hook_preStore

 protected function hook_preStore()
 {
     $q = $this->_getQuery();
     $this->project_updated = $q->dbfnNowWithTZ();
     // ensure changes of state in checkboxes is captured
     $this->project_active = (int) $this->project_active;
     $this->project_private = (int) $this->project_private;
     $this->project_target_budget = filterCurrency($this->project_target_budget);
     $this->project_url = str_replace(array('"', '"', '<', '>'), '', $this->project_url);
     $this->project_demo_url = str_replace(array('"', '"', '<', '>'), '', $this->project_demo_url);
     $this->project_owner = (int) $this->project_owner ? $this->project_owner : $this->_AppUI->user_id;
     $this->project_creator = (int) $this->project_creator ? $this->project_creator : $this->_AppUI->user_id;
     $this->project_priority = (int) $this->project_priority;
     $this->project_type = (int) $this->project_type;
     $this->project_status = (int) $this->project_status;
     // Make sure project_short_name is the right size (issue for languages with encoded characters)
     if ('' == $this->project_short_name) {
         $this->project_short_name = mb_substr($this->project_name, 0, 10);
     }
     $this->project_short_name = mb_substr($this->project_short_name, 0, 10);
     if (empty($this->project_end_date)) {
         $this->project_end_date = null;
     }
     $this->project_id = (int) $this->project_id;
     // convert dates to SQL format first
     if ($this->project_start_date) {
         $date = new w2p_Utilities_Date($this->project_start_date);
         $this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
     }
     if ($this->project_end_date) {
         $date = new w2p_Utilities_Date($this->project_end_date);
         $this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
     }
     // check project parents and reset them to self if they do not exist
     if (!$this->project_parent) {
         $this->project_parent = $this->project_id;
         $this->project_original_parent = $this->project_id;
     } else {
         $parent_project = new CProject();
         $parent_project->overrideDatabase($this->_query);
         $parent_project->load($this->project_parent);
         $this->project_original_parent = $parent_project->project_original_parent;
     }
     if (!$this->project_original_parent) {
         $this->project_original_parent = $this->project_id;
     }
     parent::hook_preStore();
 }
开发者ID:victorrod,项目名称:web2project,代码行数:48,代码来源:projects.class.php

示例4: getAllowedRecords

 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null, $unused = '')
 {
     $oPrj = new CProject();
     $oPrj->overrideDatabase($this->_query);
     $aPrjs = $oPrj->getAllowedRecords($uid, 'projects.project_id, project_name', '', null, null, 'projects');
     if (count($aPrjs)) {
         $buffer = '(event_project IN (' . implode(',', array_keys($aPrjs)) . ') OR event_project IS NULL OR event_project = \'\' OR event_project = 0)';
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer;
         } else {
             $extra['where'] = $buffer;
         }
     } else {
         // There are no allowed projects, so only allow events with no project.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND (event_project IS NULL OR event_project = \'\' OR event_project = 0) ';
         } else {
             $extra['where'] = '(event_project IS NULL OR event_project = \'\' OR event_project = 0)';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
开发者ID:illuminate3,项目名称:web2project,代码行数:22,代码来源:events.class.php

示例5: getAllowedRecords

 public function getAllowedRecords($uid, $fields = '*', $orderby = '', $index = null, $extra = null, $unused = '')
 {
     $oPrj = new CProject();
     $oPrj->overrideDatabase($this->_query);
     $aPrjs = $oPrj->getAllowedRecords($uid, 'projects.project_id, project_name', '', null, null, 'projects');
     if (count($aPrjs)) {
         $buffer = '(task_project IN (' . implode(',', array_keys($aPrjs)) . '))';
         if (isset($extra['where']) && $extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND ' . $buffer;
         } else {
             $extra['where'] = $buffer;
         }
     } else {
         // There are no allowed projects, so don't allow tasks.
         if ($extra['where'] != '') {
             $extra['where'] = $extra['where'] . ' AND 1 = 0 ';
         } else {
             $extra['where'] = '1 = 0';
         }
     }
     return parent::getAllowedRecords($uid, $fields, $orderby, $index, $extra);
 }
开发者ID:victorrod,项目名称:web2project,代码行数:22,代码来源:tasks.class.php


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