本文整理汇总了PHP中Phprojekt_Loader::getLibraryClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Phprojekt_Loader::getLibraryClass方法的具体用法?PHP Phprojekt_Loader::getLibraryClass怎么用?PHP Phprojekt_Loader::getLibraryClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phprojekt_Loader
的用法示例。
在下文中一共展示了Phprojekt_Loader::getLibraryClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
}
}
}
示例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;
}
}
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
}
示例11: saveRelation
/**
* Save the roles-user relation for one projectId.
*
* @param array $roles Array with the roles ID.
* @param array users Array with the users ID.
* @param integer $projectId The project ID.
*
* @return void
*/
public function saveRelation($roles, $users, $projectId)
{
$where = sprintf('project_id = %d', (int) $projectId);
foreach ($this->fetchAll($where) as $relation) {
$relation->delete();
}
// Save roles only for allowed users
$activeRecord = Phprojekt_Loader::getLibraryClass('Phprojekt_User_User');
$result = $activeRecord->getAllowedUsers();
foreach ($result as $user) {
$userId = $user['id'];
if (in_array($userId, $users)) {
$clone = clone $this;
$clone->roleId = $roles[$userId];
$clone->userId = $userId;
$clone->projectId = $projectId;
$clone->save();
// Reset cache
$sessionName = 'Project_Models_ProjectRoleUserPermissions-fetchUserRole-' . $projectId . '-' . $userId;
$roleNamespace = new Zend_Session_Namespace($sessionName);
$roleNamespace->unsetAll();
}
}
}
示例12: searchModuleByWordId
/**
* Get all the modules-item with the wordId.
*
* @param array $words Array with words IDs.
* @param string $operator Query operator.
* @param integer $count Limit query.
*
* @return array Array of results.
*/
public function searchModuleByWordId($words, $operator = 'AND', $count = 0)
{
$ids = array();
$result = array();
$rights = Phprojekt_Loader::getLibraryClass('Phprojekt_Item_Rights');
$userId = Phprojekt_Auth::getUserId();
$db = Phprojekt::getInstance()->getDb();
foreach ($words as $content) {
$ids[] = (int) $content['id'];
}
if (!empty($ids)) {
// Search by AND
if ($operator == 'AND') {
$sqlString = '';
$selects = array();
$first = true;
while (!empty($ids)) {
$id = array_pop($ids);
if ($first) {
$first = false;
if (!empty($ids)) {
$selects[] = $db->select()->from('search_word_module', array('item_id'))->where('word_id = ' . (int) $id);
} else {
$selects[] = $db->select()->from('search_word_module')->where('word_id = ' . (int) $id);
}
} else {
if (!empty($ids)) {
$selects[] = $db->select()->from('search_word_module', array('item_id'))->where('word_id = ' . (int) $id . ' AND item_id IN (%s)');
} else {
$selects[] = $db->select()->from('search_word_module')->where('word_id = ' . (int) $id . ' AND item_id IN (%s)');
}
}
}
$first = true;
while (!empty($selects)) {
$select = array_shift($selects)->__toString();
if ($first) {
$sqlString = $select;
$first = false;
} else {
$sqlString = sprintf($select, $sqlString);
}
}
$stmt = $db->query($sqlString);
$tmpResult = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
} else {
// Search By OR
$where = 'word_id IN (' . implode(', ', $ids) . ')';
$order = array('module_id ASC', 'item_id DESC');
$tmpResult = $this->fetchAll($where, $order)->toArray();
}
foreach ($tmpResult as $data) {
// Limit to $count results
if ((int) $count > 0 && count($result) >= $count) {
break;
}
// Only fetch records with read access
if ($rights->getItemRight($data['module_id'], $data['item_id'], $userId) > 0) {
$result[$data['module_id'] . '-' . $data['item_id']] = $data;
}
}
}
return $result;
}
示例13: jsonSaveAction
/**
* Saves the new values of the projects dates.
*
* OPTIONAL request parameters:
* <pre>
* - array <b>projects</b> Array with projectId,startDate and endDate by comma separated
* </pre>
*
* If there is an error, the save will return a Phprojekt_PublishedException,
* if not, it returns a string in JSON format with:
* <pre>
* - type => 'success'.
* - message => Success message.
* - code => 0.
* - id => 0.
* </pre>
*
* @throws Phprojekt_PublishedException On error in the action save or wrong parameters.
*
* @return void
*/
public function jsonSaveAction()
{
$projects = (array) $this->getRequest()->getParam('projects', array());
$activeRecord = Phprojekt_Loader::getModel('Project', 'Project');
$rights = Phprojekt_Loader::getLibraryClass('Phprojekt_Item_Rights');
$userId = Phprojekt_Auth::getUserId();
$this->setCurrentProjectId();
// Error check: no project received
if (empty($projects)) {
$label = Phprojekt::getInstance()->translate('Projects');
$message = Phprojekt::getInstance()->translate('No project info was received');
throw new Phprojekt_PublishedException($label . ': ' . $message);
}
foreach ($projects as $project) {
list($id, $startDate, $endDate) = explode(",", $project);
// Check: are the three values available?
if (empty($id) || empty($startDate) || empty($endDate)) {
$label = Phprojekt::getInstance()->translate('Projects');
$message = Phprojekt::getInstance()->translate('Incomplete data received');
throw new Phprojekt_PublishedException($label . ': ' . $message);
}
$id = (int) $id;
$activeRecord->find($id);
// Check: project id exists?
if (empty($activeRecord->id)) {
$label = Phprojekt::getInstance()->translate('Project');
$message = Phprojekt::getInstance()->translate('Id not found #') . $id;
throw new Phprojekt_PublishedException($label . ': ' . $message);
}
// Check: dates are valid?
$validStart = Cleaner::validate('date', $startDate, false);
$validEnd = Cleaner::validate('date', $endDate, false);
if (!$validStart || !$validEnd) {
$label = Phprojekt::getInstance()->translate('Project id #') . $id;
if (!$validStart) {
$message = Phprojekt::getInstance()->translate('Start date invalid');
} else {
$message = Phprojekt::getInstance()->translate('End date invalid');
}
throw new Phprojekt_PublishedException($label . ': ' . $message);
}
// Check: start date after end date?
$startDateTemp = strtotime($startDate);
$endDateTemp = strtotime($endDate);
if ($startDateTemp > $endDateTemp) {
$label = Phprojekt::getInstance()->translate('Project id #') . $id;
$message = Phprojekt::getInstance()->translate('Start date can not be after End date');
throw new Phprojekt_PublishedException($label . ': ' . $message);
}
$activeRecord->startDate = $startDate;
$activeRecord->endDate = $endDate;
if ($rights->getItemRight(1, $id, $userId) >= Phprojekt_Acl::WRITE) {
$activeRecord->parentSave();
}
}
$message = Phprojekt::getInstance()->translate(self::EDIT_MULTIPLE_TRUE_TEXT);
$return = array('type' => 'success', 'message' => $message, 'code' => 0, 'id' => 0);
Phprojekt_Converter_Json::echoConvert($return);
}
示例14: getBodyFields
/**
* Returns the fields part of the Notification body using a custom criterion for the Calendar module.
*
* @param Zend_Locale $lang Locale for use in translations.
*
* @return array Array with 'label' and 'value'.
*/
public function getBodyFields($lang)
{
$bodyFields = array();
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('Title', $lang), 'value' => $this->_model->title);
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('Place', $lang), 'value' => $this->_model->place);
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('Notes', $lang), 'value' => $this->_model->notes);
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('Start', $lang), 'value' => $this->translateDate($this->_model->startDateNotif, $lang) . ' ' . substr($this->_model->startDatetime, 11, 5));
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('End', $lang), 'value' => $this->translateDate($this->_model->endDateNotif, $lang) . ' ' . substr($this->_model->startDatetime, 11, 5));
$phpUser = Phprojekt_Loader::getLibraryClass('Phprojekt_User_User');
$participants = $this->_model->notifParticipants;
$participantsValue = "";
$i = 0;
$lastItem = count($participants);
// Participants field
foreach ($participants as $participant) {
$i++;
$phpUser->find((int) $participant);
$fullname = trim($phpUser->firstname . ' ' . $phpUser->lastname);
if (!empty($fullname)) {
$participantsValue .= $fullname . ' (' . $phpUser->username . ')';
} else {
$participantsValue .= $phpUser->username;
}
if ($i < $lastItem) {
$participantsValue .= ", ";
}
}
$bodyFields[] = array('label' => Phprojekt::getInstance()->translate('Participants', $lang), 'value' => $participantsValue);
if ($this->_model->rrule !== null) {
$bodyFields = array_merge($bodyFields, $this->getRruleDescriptive($this->_model->rrule, $lang));
}
return $bodyFields;
}
示例15: jsonDisableFrontendMessagesAction
/**
* Disables all frontend messages.
*
* @return void
*/
public function jsonDisableFrontendMessagesAction()
{
$notification = Phprojekt_Loader::getLibraryClass('Phprojekt_Notification');
try {
$notification->disableFrontendMessages();
$message = Phprojekt::getInstance()->translate(self::DISABLE_FRONTEND_MESSAGES_TRUE_TEXT);
$resultType = 'success';
} catch (Exception $error) {
Phprojekt::getInstance()->getLog()->debug('Error: ' . $error->message);
$message = Phprojekt::getInstance()->translate(self::DISABLE_FRONTEND_MESSAGES_FALSE_TEXT);
$resultType = 'error';
}
$return = array('type' => $resultType, 'message' => $message, 'code' => 0, 'id' => 0);
Phprojekt_Converter_Json::echoConvert($return);
}