本文整理汇总了PHP中Companies::findByIds方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::findByIds方法的具体用法?PHP Companies::findByIds怎么用?PHP Companies::findByIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Companies
的用法示例。
在下文中一共展示了Companies::findByIds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show companies index page
*
* @param void
* @return null
*/
function index()
{
if ($this->request->isApiCall()) {
$this->serveData(Companies::findByIds($this->logged_user->visibleCompanyIds()), 'companies');
} else {
$page = (int) $this->request->get('page');
if ($page < 1) {
$page = 1;
}
// if
list($companies, $pagination) = Companies::paginateActive($this->logged_user, $page, 30);
$this->smarty->assign(array('companies' => $companies, 'pagination' => $pagination));
}
// if
}
示例2: findByProject
/**
* Returns array of companies that are involved in project
* @param Project $project
* @return array
*/
function findByProject($project)
{
$people = ProjectUsers::findUsersByProject($project);
if (is_foreachable($people)) {
$company_ids = array();
foreach ($people as $person) {
if (!in_array($person->getCompanyId(), $company_ids)) {
$company_ids[] = $person->getCompanyId();
}
// if
}
// foreach
return Companies::findByIds($company_ids);
} else {
return null;
}
// if
}
示例3: subscriptions
/**
* Show people subscribed to a given object
*
* @param void
* @return null
*/
function subscriptions()
{
$this->skip_layout = $this->request->isAsyncCall();
if (!$this->active_object->canEdit($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
}
// if
$users = $this->active_project->getUsers();
if (is_foreachable($users)) {
$people = array();
$grouped_users = array();
foreach ($users as $user) {
$company_id = $user->getCompanyId();
if (!isset($people[$company_id])) {
$people[$company_id] = array('users' => null, 'company' => null);
}
// if
$people[$company_id]['users'][] = $user;
}
// foreach
$companies = Companies::findByIds(array_keys($people));
foreach ($companies as $company) {
$people[$company->getId()]['company'] = $company;
}
// foreach
$this->smarty->assign('people', $people);
} else {
$this->smarty->assign('people', null);
}
// if
}
示例4: index
/**
* Show people page
*
* @param void
* @return null
*/
function index()
{
if ($this->active_project->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$users = $this->active_project->getUsers();
// API
if ($this->request->isApiCall()) {
$project_users_data = array();
if (is_foreachable($users)) {
foreach ($users as $user) {
$user_data = array('user_id' => $user->getId(), 'role' => null, 'permissions' => array(), 'permalink' => $user->getViewUrl());
$permissions = array_keys(Permissions::findProject());
if ($user->isAdministrator()) {
$user_data['role'] = 'administrator';
} elseif ($user->isProjectManager()) {
$user_data['role'] = 'project-manager';
} elseif ($user->isProjectLeader($this->active_project)) {
$user_data['role'] = 'project-leader';
}
// if
if ($user_data['role'] === null) {
$project_role = $user->getProjectRole($this->active_project);
if (instance_of($project_role, 'Role')) {
$user_data['role'] = $project_role->getId();
} else {
$user_data['role'] = 'custom';
}
// if
foreach ($permissions as $permission) {
$user_data['permissions'][$permission] = (int) $user->getProjectPermission($permission, $this->active_project);
}
// foreach
} else {
foreach ($permissions as $permission) {
$user_data['permissions'][$permission] = PROJECT_PERMISSION_MANAGE;
}
// foreach
}
// if
$project_users_data[] = $user_data;
}
// foreach
}
// if
$this->serveData($project_users_data, 'project_users');
// Regular interface
} else {
if (is_foreachable($users)) {
$people = array();
$grouped_users = array();
//BOF:mod 20110712 ticketid237
$company_by_custom_sort = array();
foreach ($users as $user) {
$company_id = $user->getCompanyId();
if (!in_array($company_id, $company_by_custom_sort)) {
$company_by_custom_sort[] = $company_id;
}
}
asort($company_by_custom_sort);
foreach ($company_by_custom_sort as $company_id) {
$people[$company_id] = array('users' => null, 'company' => null);
}
//EOF:mod 20110712 ticketid237
foreach ($users as $user) {
$company_id = $user->getCompanyId();
if (!isset($people[$company_id])) {
$people[$company_id] = array('users' => null, 'company' => null);
}
// if
$people[$company_id]['users'][] = $user;
}
// foreach
$companies = Companies::findByIds(array_keys($people));
foreach ($companies as $company) {
$people[$company->getId()]['company'] = $company;
}
// foreach
$this->smarty->assign('people', $people);
} else {
$this->smarty->assign('people', null);
}
// if
}
// if
}
示例5: object_subscribers
/**
* Show and process object subscribers page
*
* @param void
* @return null
*/
function object_subscribers()
{
$this->skip_layout = true;
$object = null;
$object_id = $this->request->getId('object_id');
if ($object_id) {
$object = ProjectObjects::findById($object_id);
}
// if
if (!instance_of($object, 'ProjectObject')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$project = $object->getProject();
if (!instance_of($project, 'Project')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$object->canEdit($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$this->smarty->assign(array('active_project' => $project, 'active_object' => $object));
$users = $project->getUsers();
if (is_foreachable($users)) {
$people = array();
$grouped_users = array();
foreach ($users as $user) {
$company_id = $user->getCompanyId();
if (!isset($people[$company_id])) {
$people[$company_id] = array('users' => null, 'company' => null);
}
// if
$people[$company_id]['users'][] = $user;
}
// foreach
$companies = Companies::findByIds(array_keys($people));
foreach ($companies as $company) {
$people[$company->getId()]['company'] = $company;
}
// foreach
$this->smarty->assign('people', $people);
} else {
$this->smarty->assign('people', null);
}
// if
}
示例6: groupByCompany
/**
* Use array of users and organize them by category
*
* @param array $users
* @return array
*/
function groupByCompany($users)
{
$result = array();
if (is_foreachable($users)) {
$company_ids = array_unique(objects_array_extract($users, 'getCompanyId'));
if (is_foreachable($company_ids)) {
$companies = Companies::findByIds($company_ids);
foreach ($companies as $company) {
$result[$company->getId()] = array('company' => $company, 'users' => array());
}
// foreach
foreach ($users as $user) {
$result[$user->getCompanyId()]['users'][] = $user;
}
// foreach
}
// if
}
// if
return $result;
}