本文整理汇总了PHP中Companies::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::findById方法的具体用法?PHP Companies::findById怎么用?PHP Companies::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Companies
的用法示例。
在下文中一共展示了Companies::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param Request $request
* @return CompanyProfileController
*/
function __construct($request)
{
parent::__construct($request);
$company_id = $this->request->getId('company_id');
if ($company_id) {
$this->active_company = Companies::findById($company_id);
}
// if
if (instance_of($this->active_company, 'Company')) {
$this->wireframe->page_actions = array();
if (!$this->active_company->canView($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
if ($this->active_company->getIsArchived() && $this->logged_user->isPeopleManager()) {
$this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive'));
}
// if
$this->wireframe->addBreadCrumb($this->active_company->getName(), $this->active_company->getViewUrl());
// Collect company tabs
$tabs = new NamedList();
$tabs->add('overview', array('text' => str_excerpt($this->active_company->getName(), 25), 'url' => $this->active_company->getViewUrl()));
$tabs->add('people', array('text' => lang('People'), 'url' => $this->active_company->getViewUrl()));
$tabs->add('projects', array('text' => lang('Projects'), 'url' => $this->active_company->getViewUrl()));
event_trigger('on_company_tabs', array(&$tabs, &$this->logged_user, &$this->active_company));
$this->smarty->assign(array('company_tabs' => $tabs, 'company_tab' => 'overview'));
} else {
$this->active_company = new Company();
}
// if
$this->smarty->assign(array('active_company' => $this->active_company));
}
示例2: getCompany
/**
* Return invoice company
*
* @param void
* @return Company
*/
function getCompany()
{
if ($this->company === false) {
$this->company = Companies::findById($this->getCompanyId());
}
// if
return $this->company;
}
示例3: getCompany
/**
* Return relation company
*
* @param void
* @return Company
*/
function getCompany()
{
if (is_null($this->company)) {
$this->company = Companies::findById($this->getCompanyId());
}
// if
return $this->company;
}
示例4: company
/**
* Display company details
*
*/
function company()
{
$current_company = Companies::findById($this->request->get('object_id'));
if (!instance_of($current_company, 'Company')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$current_company->isOwner() && !in_array($current_company->getId(), $this->logged_user->visibleCompanyIds())) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$users = $current_company->getUsers($this->logged_user->visibleUserIds());
if (!$current_company->isOwner()) {
$projects = Projects::findByUserAndCompany($this->logged_user, $current_company);
}
$this->smarty->assign(array('current_company' => $current_company, 'current_company_users' => $users, 'current_company_projects' => $projects, "page_title" => $current_company->getName(), "page_back_url" => assemble_url('mobile_access_people')));
}
示例5: select_users
/**
* Render content for select_users popup dialog
*
* @param void
* @return null
*/
function select_users()
{
$company_id = $this->request->getId('company_id');
$company = null;
if ($company_id) {
$company = Companies::findById($company_id);
}
// if
$project_id = $this->request->getId('project_id');
$project = null;
if ($project_id) {
$project = Projects::findById($project_id);
}
// if
$exclude_user_ids = $this->request->get('exclude_user_ids');
if ($exclude_user_ids) {
$exclude_user_ids = explode(',', $exclude_user_ids);
}
// if
$selected_user_ids = $this->request->get('selected_user_ids');
if ($selected_user_ids) {
$selected_user_ids = explode(',', $selected_user_ids);
}
// if
if (is_foreachable($exclude_user_ids) && is_foreachable($selected_user_ids)) {
foreach ($selected_user_ids as $k => $v) {
if (in_array($v, $exclude_user_ids)) {
unset($selected_user_ids[$k]);
}
// if
}
// foreach
}
// if
if (is_foreachable($selected_user_ids)) {
$selected_users = Users::findByIds($selected_user_ids);
} else {
$selected_users = null;
}
// if
$grouped_users = Users::findForSelect($company, $project, $exclude_user_ids);
$this->smarty->assign(array('widget_id' => $this->request->get('widget_id'), 'grouped_users' => $grouped_users, 'selected_users' => $selected_users, 'selected_users_cycle_name' => $this->request->get('widget_id') . '_select_users'));
}
示例6: company
/**
* Show billed / canceled company invoices
*
* @param void
* @return null
*/
function company()
{
$status = $this->request->get('status') ? $this->request->get('status') : 'billed';
$company = null;
$company_id = $this->request->getId('company_id');
if ($company_id) {
$company = Companies::findById($company_id);
}
// if
if (instance_of($company, 'Company')) {
$this->wireframe->addBreadCrumb($company->getName(), assemble_url('company_invoices', array('company_id' => $company->getId())));
} else {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if ($status == 'canceled') {
$invoices = group_invoices_by_currency(Invoices::findByCompany($company, array(INVOICE_STATUS_CANCELED), 'closed_on DESC'));
} else {
$invoices = group_invoices_by_currency(Invoices::findByCompany($company, array(INVOICE_STATUS_BILLED), 'closed_on DESC'));
}
// if
$this->smarty->assign(array('company' => $company, 'invoices' => $invoices, 'status' => $status));
}
示例7: validate
/**
* Validate before save
*
* @param ValidationErrors $errors
* @return null
*/
function validate(&$errors)
{
if ($this->validatePresenceOf('email', 5)) {
if (is_valid_email($this->getEmail())) {
if (!$this->validateUniquenessOf('email')) {
$errors->addError(lang('Email address you provided is already in use'), 'email');
}
// if
} else {
$errors->addError(lang('Email value is not valid'), 'email');
}
// if
} else {
$errors->addError(lang('Email value is required'), 'email');
}
// if
if ($this->isNew()) {
if (strlen(trim($this->raw_password)) < 3) {
$errors->addError(lang('Minimal password length is 3 characters'), 'password');
}
// if
} else {
if ($this->raw_password !== false && strlen(trim($this->raw_password)) < 3) {
$errors->addError(lang('Minimal password length is 3 characters'), 'password');
}
// if
}
// if
$company_id = $this->getCompanyId();
if ($company_id) {
$company = Companies::findById($company_id);
if (!instance_of($company, 'Company')) {
$errors->addError(lang('Selected company does not exist'), 'company_id');
}
// if
} else {
$errors->addError(lang('Please select company'), 'company_id');
}
// if
if (!$this->validatePresenceOf('role_id')) {
$errors->addError(lang('Role is required'), 'role_id');
}
// if
}
示例8: can_assign_task_to_company_user
/**
* Returns true if user can assign the task or an error string if not.
* @param $user
* @param $task
* @param $company_id
* @param $user_id
* @return mixed
*/
function can_assign_task_to_company_user(User $user, ProjectTask $task, $company_id, $user_id)
{
if ($company_id != 0) {
$workspace = $task->getProject();
if ($user_id != 0) {
$assignee = Users::findById($user_id);
if (!$assignee instanceof User) {
return lang('error assign task user dnx');
} else {
if (!can_assign_task($user, $workspace, $assignee)) {
return lang('error assign task permissions user');
}
}
} else {
$company = Companies::findById($company_id);
if (!$company instanceof Company) {
return lang('error assign task company dnx');
} else {
if (!can_assign_task($user, $workspace, $company)) {
return lang('error assign task permissions company');
}
}
}
}
return true;
}
示例9: is_array
echo $companyId;
?>
" class="company-users" <?php
echo is_array($users) == true ? 'style ="margin-bottom: 10px;"' : '';
?>
>
<?php
if (is_array($users) && count($users)) {
?>
<div onclick="og.subscribeCompany(this)" class="container-div company-name<?php
echo $allChecked ? ' checked' : '';
?>
" onmouseout="og.rollOut(this,true)" onmouseover="og.rollOver(this)">
<?php
$theCompany = Companies::findById($companyId);
?>
<label for="<?php
echo $genid;
?>
notifyCompany<?php
echo $theCompany->getId();
?>
" style="background: url('<?php
echo $theCompany->getLogoUrl();
?>
') no-repeat;"><?php
echo clean($theCompany->getName());
?>
</label><br/>
</div>
示例10: add
/**
* Add user
*
* @access public
* @param void
* @return null
*/
function add()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$max_users = config_option('max_users');
if ($max_users && Users::count() >= $max_users) {
flash_error(lang('maximum number of users reached error'));
ajx_current("empty");
return;
}
$this->setTemplate('add_user');
$company = Companies::findById(get_id('company_id'));
if (!$company instanceof Company) {
$company = owner_company();
}
// if
if (!User::canAdd(logged_user(), $company)) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$user = new User();
$user_data = array_var($_POST, 'user');
if (!is_array($user_data)) {
//if it is a new user
$contact_id = get_id('contact_id');
$contact = Contacts::findById($contact_id);
if ($contact instanceof Contact) {
//if it will be created from a contact
$user_data = array('username' => $this->generateUserNameFromContact($contact), 'display_name' => $contact->getFirstname() . $contact->getLastname(), 'email' => $contact->getEmail(), 'contact_id' => $contact->getId(), 'password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $contact->getTimezone(), 'create_contact' => false, 'type' => 'normal', 'can_manage_time' => true);
// array
} else {
// if it is new, and created from admin interface
$user_data = array('password_generator' => 'random', 'company_id' => $company->getId(), 'timezone' => $company->getTimezone(), 'create_contact' => true, 'send_email_notification' => true, 'type' => 'normal', 'can_manage_time' => true);
// array
}
}
// if
$permissions = ProjectUsers::getNameTextArray();
tpl_assign('user', $user);
tpl_assign('company', $company);
tpl_assign('permissions', $permissions);
tpl_assign('user_data', $user_data);
tpl_assign('billing_categories', BillingCategories::findAll());
if (is_array(array_var($_POST, 'user'))) {
if (!array_var($user_data, 'createPersonalProject')) {
$user_data['personal_project'] = 0;
}
try {
DB::beginWork();
$user = $this->createUser($user_data, array_var($_POST, 'permissions'));
$object_controller = new ObjectController();
$object_controller->add_custom_properties($user);
DB::commit();
flash_success(lang('success add user', $user->getDisplayName()));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
ajx_current("empty");
flash_error($e->getMessage());
}
// try
}
// if
}
示例11: archive
/**
* Projects Arhive
*
* @param void
* @return null
*/
function archive()
{
if ($this->request->isApiCall()) {
$this->serveData(Projects::findByUser($this->logged_user), 'projects');
}
// if
$per_page = 10;
$page = (int) $this->request->get('page');
if ($page < 1) {
$page = 1;
}
// if
if (!$this->logged_user->isOwner()) {
$group_by = 'group';
} else {
$group_by = $this->request->get('group_by');
if ($group_by != 'client') {
$group_by = 'group';
}
// if
}
// if
$filter_by_status = $this->request->get('filter');
if (is_null($filter_by_status)) {
$filter_by_status = 'all';
}
// if
switch ($filter_by_status) {
case 'all':
$statuses = array(PROJECT_STATUS_COMPLETED, PROJECT_STATUS_CANCELED, PROJECT_STATUS_PAUSED);
break;
case 'completed':
$statuses = array(PROJECT_STATUS_COMPLETED);
break;
case 'paused':
$statuses = array(PROJECT_STATUS_PAUSED);
break;
case 'canceled':
$statuses = array(PROJECT_STATUS_CANCELED);
break;
default:
$statuses = array(PROJECT_STATUS_COMPLETED, PROJECT_STATUS_CANCELED, PROJECT_STATUS_PAUSED);
break;
}
// switch project status filter
$this->smarty->assign(array('group_by' => $group_by, 'filter' => $filter_by_status));
if ($group_by == 'group') {
$group = null;
$group_id = $this->request->getId('group_id');
if ($group_id) {
$group = ProjectGroups::findById($group_id);
}
// if
if (instance_of($group, 'ProjectGroup')) {
list($projects, $pagination) = Projects::paginateByUserAndGroup($this->logged_user, $group, $statuses, $page, $per_page, true);
} else {
list($projects, $pagination) = Projects::paginateByUser($this->logged_user, $statuses, $page, $per_page, true);
}
// if
$this->smarty->assign(array('projects' => $projects, 'pagination' => $pagination, 'groups' => ProjectGroups::findAll($this->logged_user), 'selected_group' => $group));
} else {
$company = null;
$company_id = $this->request->getId('company_id');
if ($company_id) {
$company = Companies::findById($company_id);
}
// if
if (!instance_of($company, 'Company')) {
$company = $this->owner_company;
}
// if
list($projects, $pagination) = Projects::paginateByUserAndCompany($this->logged_user, $company, $statuses, $page, $per_page, true);
$this->smarty->assign(array('projects' => $projects, 'pagination' => $pagination, 'companies' => Companies::findClients($this->logged_user), 'selected_company' => $company));
}
// if
}
示例12: getCompany
/**
* Return owner company
*
* @access public
* @param void
* @return Company
*/
function getCompany()
{
return Companies::findById($this->getCompanyId());
}
示例13: get_company_data
function get_company_data()
{
ajx_current("empty");
$id = array_var($_GET, 'id');
$company = Companies::findById($id);
if ($company) {
ajx_extra_data(array("id" => $company->getId(), "address" => $company->getAddress(), "state" => $company->getState(), "city" => $company->getCity(), "country" => $company->getCountry(), "zipcode" => $company->getZipcode(), "webpage" => $company->getHomepage(), "phoneNumber" => $company->getPhoneNumber(), "faxNumber" => $company->getFaxNumber()));
} else {
ajx_extra_data(array("id" => 0));
}
}
示例14: delete_logo
/**
* Delete company logo
*
* @param void
* @return null
*/
function delete_logo()
{
if (!logged_user()->isAdministrator(owner_company())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard');
}
// if
$company = Companies::findById(get_id());
if (!$company instanceof Company) {
flash_error(lang('company dnx'));
$this->redirectToReferer(get_url('administration', 'clients'));
}
// if
try {
DB::beginWork();
$company->deleteLogo();
$company->save();
ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_EDIT);
DB::commit();
flash_success(lang('success delete company logo'));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete company logo'));
}
// try
$this->redirectToUrl($company->getEditLogoUrl());
}
示例15: getAssignedToCompany
/**
* Return responsible company
*
* @access public
* @param void
* @return Company
*/
protected function getAssignedToCompany()
{
return Companies::findById($this->getAssignedToCompanyId());
}