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


PHP Phprojekt_Loader类代码示例

本文整理汇总了PHP中Phprojekt_Loader的典型用法代码示例。如果您正苦于以下问题:PHP Phprojekt_Loader类的具体用法?PHP Phprojekt_Loader怎么用?PHP Phprojekt_Loader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getStatistics

 /**
  * Get all the values for the current project and sub-projects and return 3 array:
  * 1. With Projects names.
  * 2. With users names.
  * 3. Relations Projects-User-Bookings.
  *
  * @param string  $startDate Start date for make the query.
  * @param string  $endDate   End date for make the query.
  * @param integer $projectId Current Project ID.
  *
  * @return array Array with 'users', 'projects' and 'rows'.
  */
 public function getStatistics($startDate, $endDate, $projectId)
 {
     $data['data'] = array();
     $data['data']['users'] = array();
     $data['data']['projects'] = array();
     $data['data']['rows'] = array();
     // Get Sub-Projects
     $activeRecord = Phprojekt_Loader::getModel('Project', 'Project');
     $tree = new Phprojekt_Tree_Node_Database($activeRecord, $projectId);
     $tree = $tree->setup();
     $projectsId = array(0);
     foreach ($tree as $node) {
         if ($node->id) {
             $projectsId[] = (int) $node->id;
             $data['data']['projects'][$node->id] = $node->getDepthDisplay('title');
         }
     }
     // Get Timecard
     $model = Phprojekt_Loader::getModel('Timecard', 'Timecard');
     $where = sprintf('(DATE(start_datetime) >= %s AND DATE(start_datetime) <= %s AND project_id IN (%s))', $model->_db->quote($startDate), $model->_db->quote($endDate), implode(", ", $projectsId));
     $records = $model->fetchAll($where);
     $users = Phprojekt_Loader::getLibraryClass('Phprojekt_User_User');
     foreach ($records as $record) {
         if (!isset($data['data']['users'][$record->ownerId])) {
             $user = $users->findUserById($record->ownerId);
             $data['data']['users'][$record->ownerId] = $user->username;
         }
         if (!isset($data['data']['rows'][$record->projectId][$record->ownerId])) {
             $data['data']['rows'][$record->projectId][$record->ownerId] = 0;
         }
         $data['data']['rows'][$record->projectId][$record->ownerId] += $record->minutes;
     }
     return $data;
 }
开发者ID:joerch,项目名称:PHProjekt,代码行数:46,代码来源:Statistic.php

示例2: jsonGetModulesAccessAction

 /**
  * Returns all the modules and the access for one roleId.
  *
  * Returns a list of all the modules with:
  * <pre>
  *  - id       => id of the module.
  *  - name     => Name of the module.
  *  - label    => Display for the module.
  *  - none     => True or false for none access.
  *  - read     => True or false for read access.
  *  - write    => True or false for write access.
  *  - access   => True or false for access access.
  *  - create   => True or false for create access.
  *  - copy     => True or false for copy access.
  *  - delete   => True or false for delete access.
  *  - download => True or false for download access.
  *  - admin    => True or false for admin access.
  * </pre>
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - integer <b>id</b> The role id for consult.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @return void
  */
 public function jsonGetModulesAccessAction()
 {
     $role = Phprojekt_Loader::getLibraryClass('Phprojekt_Role_RoleModulePermissions');
     $roleId = (int) $this->getRequest()->getParam('id', null);
     $modules = $role->getRoleModulePermissionsById($roleId);
     Phprojekt_Converter_Json::echoConvert($modules);
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:35,代码来源:RoleController.php

示例3: setConfigurations

 /**
  * Save the configurations into the table.
  *
  * @param array $params Array with values to save.
  *
  * @return void
  */
 public function setConfigurations($params)
 {
     $fields = $this->getFieldDefinition(Phprojekt_ModelInformation_Default::ORDERING_FORM);
     $configuration = Phprojekt_Loader::getLibraryClass('Phprojekt_Configuration');
     $configuration->setModule('General');
     foreach ($fields as $data) {
         foreach ($params as $key => $value) {
             if ($key == $data['key']) {
                 if ($key == 'companyName') {
                     // Update Root node
                     $project = Phprojekt_Loader::getModel('Project', 'Project');
                     $project->find(1);
                     $project->title = $value;
                     $project->parentSave();
                 }
                 $where = sprintf('key_value = %s AND module_id = 0', $configuration->_db->quote($key));
                 $record = $configuration->fetchAll($where);
                 if (isset($record[0])) {
                     $record[0]->keyValue = $key;
                     $record[0]->value = $value;
                     $record[0]->save();
                 } else {
                     $configuration->moduleId = 0;
                     $configuration->keyValue = $key;
                     $configuration->value = $value;
                     $configuration->save();
                 }
                 break;
             }
         }
     }
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:39,代码来源:Configuration.php

示例4: setSettings

 /**
  * Save the settings for the timecard
  *
  * @param array $params $_POST values
  *
  * @return void
  */
 public function setSettings($params)
 {
     $namespace = new Zend_Session_Namespace(Phprojekt_Setting::IDENTIFIER . Phprojekt_Auth::getUserId());
     $fields = $this->getFieldDefinition(Phprojekt_ModelInformation_Default::ORDERING_FORM);
     foreach ($fields as $data) {
         foreach ($params as $key => $value) {
             if ($key == $data['key']) {
                 $setting = Phprojekt_Loader::getLibraryClass('Phprojekt_Setting');
                 $setting->setModule('Timecard');
                 if ($key == 'favorites') {
                     $value = serialize($value);
                 }
                 $where = sprintf('user_id = %d AND key_value = %s AND module_id = %d', (int) Phprojekt_Auth::getUserId(), $setting->_db->quote($key), (int) Phprojekt_Module::getId('Timecard'));
                 $record = $setting->fetchAll($where);
                 if (isset($record[0])) {
                     $record[0]->keyValue = $key;
                     $record[0]->value = $value;
                     $record[0]->save();
                 } else {
                     $setting->userId = Phprojekt_Auth::getUserId();
                     $setting->moduleId = Phprojekt_Module::getId('Timecard');
                     $setting->keyValue = $key;
                     $setting->value = $value;
                     $setting->identifier = 'Timecard';
                     $setting->save();
                 }
                 $namespace->{$key} = $value;
                 break;
             }
         }
     }
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:39,代码来源:Setting.php

示例5: getTo

 /**
  * Returns the recipients for this Helpdesk item.
  *
  * @return array Array with user IDs.
  */
 public function getTo()
 {
     $userId = Phprojekt_Auth::getUserId();
     // Gets only the recipients with at least a 'read' right.
     $recipients = parent::getTo();
     // Assigned user
     if (isset($this->_model->assigned) && $this->_model->assigned != $userId) {
         $recipients[] = $this->_model->assigned;
     }
     // Author user
     if (isset($this->_model->author) && $this->_model->author != $userId) {
         $recipients[] = $this->_model->author;
     }
     // Owner user
     if (isset($this->_model->ownerId) && $this->_model->ownerId != $userId) {
         $recipients[] = $this->_model->ownerId;
     }
     // If the item has been reassigned, add the previous assigned user to the recipients
     $history = Phprojekt_Loader::getLibraryClass('Phprojekt_History');
     $olUser = $history->getLastAssignedUser($this->_model, 'assigned');
     if ($olUser > 0) {
         $recipients[] = $olUser;
     }
     // Return without duplicates
     return array_unique($recipients);
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:31,代码来源:Notification.php

示例6: testConvertTree

 /**
  * Test json convert tree
  */
 public function testConvertTree()
 {
     $converted = '{}&&({"identifier":"id","label":"name","items":[{"name"';
     $object = Phprojekt_Loader::getModel('Project', 'Project');
     $tree = new Phprojekt_Tree_Node_Database($object, 1);
     $tree = $tree->setup();
     $result = Phprojekt_Converter_Json::convert($tree);
     $this->assertEquals($converted, substr($result, 0, strlen($converted)));
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:12,代码来源:JsonTest.php

示例7: jsonSearchAction

 /**
  * Search for words.
  *
  * Returns a list of items that have the word, sorted by module with:
  * <pre>
  *  - id            => id of the item found.
  *  - moduleId      => id of the module.
  *  - moduleName    => Name of the module.
  *  - moduleLabel   => Display for the module.
  *  - firstDisplay  => Firts display for the item (Ej. title).
  *  - secondDisplay => Second display for the item (Ej. notes).
  *  - projectId     => Parent project id of the item.
  * </pre>
  *
  * REQUIRES request parameters:
  * <pre>
  *  - string <b>words</b> An string of words (Will be separated by the spaces).
  * </pre>
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - integer <b>count</b> Number of results.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @return void
  */
 public function jsonSearchAction()
 {
     $words = (string) $this->getRequest()->getParam('words');
     $count = (int) $this->getRequest()->getParam('count', null);
     $offset = (int) $this->getRequest()->getParam('start', null);
     $search = Phprojekt_Loader::getLibraryClass('Phprojekt_Search');
     $results = $search->search($words, $count);
     Phprojekt_Converter_Json::echoConvert($results);
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:37,代码来源:SearchController.php

示例8: testConvert

 /**
  * Test csv converter
  */
 public function testConvert()
 {
     $convertedFields = '"Title","Start date","End date","Priority","Status","Complete percent"';
     $convertedValues = '"Invisible Root","","","","Offered","0.00"';
     $object = Phprojekt_Loader::getModel('Project', 'Project');
     $records = $object->fetchAll();
     $result = Phprojekt_Converter_Csv::convert($records);
     $this->assertContains($convertedFields, $result);
     $this->assertContains($convertedValues, $result);
     $result = Phprojekt_Converter_Csv::convert($object->find(1));
     $this->assertEquals($result, "");
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:15,代码来源:CsvTest.php

示例9: testDefaultModelsDefault

 /**
  * Test valid method
  *
  */
 public function testDefaultModelsDefault()
 {
     $defaultModel = Phprojekt_Loader::getModel('Default', 'Default');
     $this->assertEquals($defaultModel->valid(), false);
     $this->assertEquals($defaultModel->save(), false);
     $this->assertEquals($defaultModel->getRights(), array());
     $this->assertEquals($defaultModel->recordValidate(), true);
     $this->assertEquals($defaultModel->getFieldsForFilter(), array());
     $this->assertEquals($defaultModel->find(), null);
     $this->assertEquals($defaultModel->fetchAll(), null);
     $this->assertEquals($defaultModel->current(), null);
     $this->assertEquals($defaultModel->rewind(), null);
     $this->assertEquals($defaultModel->next(), null);
     $this->assertEquals($defaultModel->getInformation(), null);
     $this->assertEquals($defaultModel->key(), null);
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:20,代码来源:DefaultTest.php

示例10: getRoleModulePermissionsById

 /**
  * Return all the modules in an array and the access if exists.
  *
  * @param integer $roleId The role ID.
  *
  * @return array Array with 'id', 'name', 'label' and the access.
  */
 public function getRoleModulePermissionsById($roleId)
 {
     $modules = array();
     $model = Phprojekt_Loader::getLibraryClass('Phprojekt_Module_Module');
     foreach ($model->fetchAll('(save_type = 0 OR save_type = 2)', 'name ASC') as $module) {
         $modules['data'][$module->id] = array();
         $modules['data'][$module->id]['id'] = $module->id;
         $modules['data'][$module->id]['name'] = $module->name;
         $modules['data'][$module->id]['label'] = Phprojekt::getInstance()->translate($module->label, null, $module->name);
         $modules['data'][$module->id] = array_merge($modules['data'][$module->id], Phprojekt_Acl::convertBitmaskToArray(0));
     }
     $where = 'role_module_permissions.role_id = ' . (int) $roleId;
     foreach ($this->fetchAll($where) as $right) {
         if (isset($modules['data'][$right->moduleId])) {
             $modules['data'][$right->moduleId] = array_merge($modules['data'][$right->moduleId], Phprojekt_Acl::convertBitmaskToArray($right->access));
         }
     }
     return $modules;
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:26,代码来源:RoleModulePermissions.php

示例11: getProjectModulePermissionsById

 /**
  * Return all the modules in an array and the permission if exists.
  *
  * @param integer $projectId The Project ID.
  *
  * @return array Array with 'id', 'name', 'label' and 'inProject'.
  */
 function getProjectModulePermissionsById($projectId)
 {
     $modules = array();
     $model = Phprojekt_Loader::getLibraryClass('Phprojekt_Module_Module');
     foreach ($model->fetchAll('active = 1 AND (save_type = 0 OR save_type = 2)', 'name ASC') as $module) {
         $modules['data'][$module->id] = array();
         $modules['data'][$module->id]['id'] = (int) $module->id;
         $modules['data'][$module->id]['name'] = $module->name;
         $modules['data'][$module->id]['label'] = Phprojekt::getInstance()->translate($module->label, null, $module->name);
         $modules['data'][$module->id]['inProject'] = false;
     }
     $where = sprintf('project_module_permissions.project_id = %d AND module.active = 1', (int) $projectId);
     $select = ' module.id AS module_id ';
     $join = ' RIGHT JOIN module ON ( module.id = project_module_permissions.module_id ';
     $join .= ' AND (module.save_type = 0 OR module.save_type = 2) )';
     foreach ($this->fetchAll($where, 'module.name ASC', null, null, $select, $join) as $right) {
         $modules['data'][$right->moduleId]['inProject'] = true;
     }
     return $modules;
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:27,代码来源:ProjectModulePermissions.php

示例12: expandIdList

 /**
  * Helper to create an array of users.
  *
  * @param string $idList   Comma-separated list of user ids.
  * @param string $idListNN Optional additional lists of comma-separated user ids.
  *
  * @return array Array with 'id' and 'display'
  */
 public static function expandIdList($idList = '')
 {
     if (1 < ($num = func_num_args())) {
         for ($i = 1; $i < $num; $i++) {
             $addList = (string) func_get_arg($i);
             if ("" != $addList) {
                 $idList .= ',' . $addList;
             }
         }
     }
     $data = array();
     if (!empty($idList)) {
         $user = Phprojekt_Loader::getLibraryClass('Phprojekt_User_User');
         $display = $user->getDisplay();
         $userList = $user->fetchAll(sprintf('id IN (%s)', $idList), $display);
         foreach ($userList as $record) {
             $data[] = array('id' => (int) $record->id, 'display' => $record->applyDisplay($display, $record));
         }
     }
     return $data;
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:29,代码来源:Userlist.php

示例13: jsonListAction

 /**
  * Returns the list of actions done in one item.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>moduleId</b> id of the module (if moduleName is sent, this is not necessary).
  *  - integer <b>itemId</b>   id of the item.
  * </pre>
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - integer <b>userId</b>     To filter by user id.
  *  - string  <b>moduleName</b> Name of the module (if moduleId is sent, this is not necessary).
  *  - date    <b>startDate</b>  To filter by start date.
  *  - date    <b>endDate</b>    To filter by end date.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @throws Phprojekt_PublishedException On missing or wrong moduleId or itemId.
  *
  * @return void
  */
 public function jsonListAction()
 {
     $moduleId = (int) $this->getRequest()->getParam('moduleId', null);
     $itemId = (int) $this->getRequest()->getParam('itemId', null);
     $userId = (int) $this->getRequest()->getParam('userId', null);
     $moduleName = Cleaner::sanitize('alnum', $this->getRequest()->getParam('moduleName', 'Default'));
     $startDate = Cleaner::sanitize('date', $this->getRequest()->getParam('startDate', null));
     $endDate = Cleaner::sanitize('date', $this->getRequest()->getParam('endDate', null));
     $this->setCurrentProjectId();
     if (empty($moduleId)) {
         $moduleId = Phprojekt_Module::getId($moduleName);
     }
     if (empty($itemId) || empty($moduleId)) {
         throw new Phprojekt_PublishedException("Invalid module or item");
     } else {
         $history = Phprojekt_Loader::getLibraryClass('Phprojekt_History');
         $data = $history->getHistoryData(null, $itemId, $moduleId, $startDate, $endDate, $userId);
         $data = array('data' => $data);
         Phprojekt_Converter_Json::echoConvert($data);
     }
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:44,代码来源:HistoryController.php

示例14: jsonDeleteAction

 /**
  * Deletes a module.
  *
  * Deletes the module entries, the module itself,
  * the databasemanager entry and the table itself.
  *
  * REQUIRES request parameters:
  * <pre>
  *  - integer <b>id</b> id of the item to delete.
  * </pre>
  *
  * The return is a string in JSON format with:
  * <pre>
  *  - type    => 'success'.
  *  - message => Success message.
  *  - id      => id of the deleted item.
  * </pre>
  *
  * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete.
  *
  * @return void
  */
 public function jsonDeleteAction()
 {
     $id = (int) $this->getRequest()->getParam('id');
     if (empty($id)) {
         throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400);
     }
     $model = $this->getModelObject()->find($id);
     if ($model instanceof Phprojekt_ActiveRecord_Abstract) {
         if (is_dir(PHPR_CORE_PATH . $model->name)) {
             throw new Zend_Controller_Action_Exception(self::CAN_NOT_DELETE_SYSTEM_MODULE, 422);
         }
         $databaseModel = Phprojekt_Loader::getModel($model->name, $model->name);
         if ($databaseModel instanceof Phprojekt_Item_Abstract) {
             $databaseManager = new Phprojekt_DatabaseManager($databaseModel);
             if (Default_Helpers_Delete::delete($model)) {
                 $return = $databaseManager->deleteModule();
             } else {
                 $return = false;
             }
         } else {
             $return = Default_Helpers_Delete::delete($model);
         }
         if ($return === false) {
             $message = Phprojekt::getInstance()->translate('The module can not be deleted');
             $type = 'error';
         } else {
             Phprojekt::removeControllersFolders();
             $message = Phprojekt::getInstance()->translate('The module was deleted correctly');
             $type = 'success';
         }
         $return = array('type' => $type, 'message' => $message, 'id' => $id);
         Phprojekt_Converter_Json::echoConvert($return);
     } else {
         throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404);
     }
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:58,代码来源:ModuleController.php

示例15: getModel

 /**
  * Get the object class to use for manage the Configuration.
  *
  * @return mix Configuration class.
  */
 public function getModel()
 {
     if (null === $this->_object) {
         // System configuration
         if ($this->_module == 'General') {
             $this->_object = Phprojekt_Loader::getModel('Core', sprintf('%s_Configuration', $this->_module));
         } else {
             $this->_object = Phprojekt_Loader::getModel($this->_module, 'Configuration');
         }
     }
     return $this->_object;
 }
开发者ID:joerch,项目名称:PHProjekt,代码行数:17,代码来源:Configuration.php


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