本文整理汇总了PHP中owner_company函数的典型用法代码示例。如果您正苦于以下问题:PHP owner_company函数的具体用法?PHP owner_company怎么用?PHP owner_company使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了owner_company函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isMemberOfOwnerCompany
/**
* Usually we check if user is member of owner company so this is the shortcut method
*
* @param void
* @return boolean
*/
function isMemberOfOwnerCompany()
{
if (is_null($this->is_member_of_owner_company)) {
$this->is_member_of_owner_company = $this->isMemberOf(owner_company());
}
return $this->is_member_of_owner_company;
}
示例2: authenticate
/**
* authenticate
*
* @param string $name
* @param string $password
* @return User of false
*/
function authenticate($login_data)
{
$username = array_var($login_data, 'username');
$password = array_var($login_data, 'password');
if (trim($username == '')) {
throw new Error('username value missing');
}
// if
if (trim($password) == '') {
throw new Error('password value missing');
}
// if
$user = Users::getByUsername($username, owner_company());
if (!$user instanceof User) {
throw new Error('invalid login data');
}
// if
if (!$user->isValidPassword($password)) {
throw new Error('invalid login data');
}
// if
//if (!$user->isDisabled()) {
// throw new Error('account disabled');
//} // if
return $user;
}
示例3: getCompaniesByProjects
/**
* Return all companies that are on specific projects, determined by a CVS list of project ids.
*
* @access public
* @param string $projects_csv CSV list of projects
* @param string $additional_conditions Additional SQL conditions
* @param bool $include_owner Include the owner company
* @return array Array of Companies
*/
static function getCompaniesByProjects($projects_csv, $additional_conditions = null, $include_owner = true)
{
$companies = array();
$companies_table = Companies::instance()->getTableName(true);
$project_companies_table = ProjectCompanies::instance()->getTableName(true);
// Restrict result only on owner company
$ownerCond = '';
if (!$include_owner) {
$owner_id = owner_company()->getId();
$ownerCond = "{$companies_table}.`client_of_id` = '{$owner_id}' AND ";
}
$sql = "SELECT {$companies_table}.* FROM {$companies_table}, {$project_companies_table} WHERE {$ownerCond} ({$companies_table}.`id` = {$project_companies_table}.`company_id` AND {$project_companies_table}.`project_id` IN ( " . $projects_csv . '))';
if (trim($additional_conditions) != '') {
$sql .= " AND ({$additional_conditions}) ORDER BY {$companies_table}.`name`";
}
$rows = DB::executeAll($sql);
if (is_array($rows)) {
foreach ($rows as $row) {
$companies[] = Companies::instance()->loadFromRow($row);
}
// foreach
}
// if
return count($companies) ? $companies : null;
}
示例4: console_create_user
function console_create_user($args)
{
$fname = array_shift($args);
$lname = array_shift($args);
$email = array_shift($args);
$admin = array_shift($args) == 'true';
if (is_null($fname) || is_null($lname) || is_null($email)) {
throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
}
$display_name = $fname . " " . $lname;
$username = str_replace(" ", "_", strtolower($display_name));
$user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
// array
try {
DB::beginWork();
$user = create_user($user_data, $admin, '');
if (!$user->getContact() instanceof Contact) {
$contact = new Contact();
$contact->setFirstName($fname);
$contact->setLastName($lname);
$contact->setEmail($email);
$contact->setUserId($user->getId());
$contact->save();
}
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
}
}
示例5: select_company
/**
* Render select company box
*
* @param integer $selected ID of selected company
* @param array $attributes Additional attributes
* @return string
*/
function select_company($name, $selected = null, $attributes = null, $allow_none = true, $check_permissions = false)
{
if (!$check_permissions) {
$companies = Contacts::findAll(array('conditions' => 'is_company = 1 AND trashed_by_id = 0 AND archived_by_id = 0 ', 'order' => 'first_name ASC'));
} else {
$companies = Contacts::getVisibleCompanies(logged_user(), "`id` <> " . owner_company()->getId());
if (logged_user()->isMemberOfOwnerCompany() || owner_company()->canAddUser(logged_user())) {
// add the owner company
$companies = array_merge(array(owner_company()), $companies);
}
}
if ($allow_none) {
$options = array(option_tag(lang('none'), 0));
} else {
$options = array();
}
if (is_array($companies)) {
foreach ($companies as $company) {
$option_attributes = $company->getId() == $selected ? array('selected' => 'selected') : null;
$company_name = $company->getObjectName();
$options[] = option_tag($company_name, $company->getId(), $option_attributes);
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例6: loginUser
protected function loginUser($username, $password) {
if ($this->checkUser($username, $password)) {
$user = Users::getByUsername($username, owner_company());
CompanyWebsite::instance()->logUserIn($user, false);
return true;
} else return false;
}
示例7: forgotPassword
/**
* Reset password and send forgot password email to the user
*
* @param User $user
* @return boolean
* @throws NotifierConnectionError
*/
static function forgotPassword(User $user)
{
$administrator = owner_company()->getCreatedBy();
$new_password = $user->resetPassword(true);
tpl_assign('user', $user);
tpl_assign('new_password', $new_password);
return self::sendEmail(self::prepareEmailAddress($user->getEmail(), $user->getDisplayName()), self::prepareEmailAddress($administrator->getEmail(), $administrator->getDisplayName()), lang('your password'), tpl_fetch(get_template_path('forgot_password', 'notifier')));
// send
}
示例8: __construct
/**
* Construct the ApplicationController
*
* @param void
* @return ApplicationController
*/
function __construct()
{
parent::__construct();
prepare_company_website_controller($this, 'administration');
// Access permissios
if (!logged_user()->isAdministrator(owner_company())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard');
}
// if
}
示例9: __construct
function __construct() {
parent::__construct();
prepare_company_website_controller($this, 'website');
ajx_set_panel("administration");
// Access permissios
if(!logged_user()->isCompanyAdmin(owner_company())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
} // if
}
示例10: getCompaniesByProjects
/**
* Return all companies that are on specific projects, determined by a CVS list of project ids.
*
* @access public
* @param string $projects_csv CSV list of projects
* @param string $additional_conditions Additional SQL conditions
* @param bool $include_owner Include the owner company
* @return array Array of Companies
*/
static function getCompaniesByProjects($projects_csv, $additional_conditions = null, $include_owner = true)
{
$companies = array();
$companies_table = self::instance()->getTableName(true);
$project_objects_table = WorkspaceObjects::instance()->getTableName(true);
// Restrict result only on owner company
$ownerCond = '';
if (!$include_owner) {
$owner_id = owner_company()->getId();
$ownerCond = "{$companies_table}.`client_of_id` = '{$owner_id}' AND ";
}
$wsCond = self::getWorkspaceString($projects_csv);
$conditions = $ownerCond != '' ? "{$ownerCond} AND {$wsCond}" : $wsCond;
if (trim($additional_conditions) != '') {
$conditions .= " AND ({$additional_conditions})";
}
return self::findAll(array('conditions' => $conditions, 'order' => '`name`'));
}
示例11: getCompaniesByProject
/**
* Return all companies that are on specific project. Owner company is excluded from
* this listing (only client companies are returned)
*
* @access public
* @param Project $project
* @param string $additional_conditions Additional SQL conditions
* @return array
*/
static function getCompaniesByProject(Project $project, $additional_conditions = null)
{
$companies_table = Companies::instance()->getTableName(true);
$project_companies_table = ProjectCompanies::instance()->getTableName(true);
// Restrict result only on owner company
$owner_id = owner_company()->getId();
$companies = array();
$sql = "SELECT {$companies_table}.* FROM {$companies_table}, {$project_companies_table} WHERE ({$companies_table}.`client_of_id` = '{$owner_id}') AND ({$companies_table}.`id` = {$project_companies_table}.`company_id` AND {$project_companies_table}.`project_id` = " . DB::escape($project->getId()) . ')';
if (trim($additional_conditions) != '') {
$sql .= " AND ({$additional_conditions})";
}
$rows = DB::executeAll($sql);
if (is_array($rows)) {
foreach ($rows as $row) {
$companies[] = Companies::instance()->loadFromRow($row);
}
// foreach
}
// if
return count($companies) ? $companies : null;
}
示例12: lang
if (trim($changeset->getComment())) {
echo lang('comment') . ":\n";
echo $changeset->getComment();
}
// if
echo "\n----------------\n\n";
}
?>
<?php
echo lang('view new ticket');
?>
:
- <?php
echo str_replace('&', '&', $ticket->getViewUrl());
?>
Company: <?php
echo owner_company()->getName();
?>
Project: <?php
echo $ticket->getProject()->getName();
?>
--
<?php
echo ROOT_URL;
示例13: get_companies_json
function get_companies_json() {
$data = array();
$check_permissions = array_var($_REQUEST, 'check_p');
$allow_none = array_var($_REQUEST, 'allow_none', true);
if (!$check_permissions) {
$comp_rows = DB::executeAll("SELECT c.object_id, c.first_name FROM ".TABLE_PREFIX."contacts c INNER JOIN ".TABLE_PREFIX."objects o ON o.id=c.object_id
WHERE c.is_company = 1 AND o.trashed_by_id = 0 AND o.archived_by_id = 0 ORDER BY c.first_name ASC");
} else {
$companies = Contacts::getVisibleCompanies(logged_user(), "`id` <> " . owner_company()->getId());
if (logged_user()->isMemberOfOwnerCompany() || owner_company()->canAddUser(logged_user())) {
// add the owner company
$companies = array_merge(array(owner_company()), $companies);
}
}
if ($allow_none) {
$data[] = array('id' => 0, 'name' => lang('none'));
}
if (isset($comp_rows)) {
foreach ($comp_rows as $row) {
$data[] = array('id' => $row['object_id'], 'name' => $row['first_name']);
}
} else if (isset($companies)) {
foreach ($companies as $company) {
$data[] = array('id' => $company->getId(), 'name' => $company->getObjectName());
}
}
$this->setAutoRender(false);
echo json_encode($data);
ajx_current("empty");
}
示例14: permissions
/**
* Show permission update form
*
* @param void
* @return null
*/
function permissions()
{
if (!active_project()->canChangePermissions(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$project_init = array_var($_GET, 'project_init');
tpl_assign('project_init', $project_init);
tpl_assign('project_users', active_project()->getUsers(false));
tpl_assign('project_companies', active_project()->getCompanies());
tpl_assign('user_projects', logged_user()->getProjects());
$permissions = PermissionManager::getPermissionsText();
tpl_assign('permissions', $permissions);
$companies = array(owner_company());
$clients = owner_company()->getClientCompanies();
if (is_array($clients)) {
$companies = array_merge($companies, $clients);
}
// if
tpl_assign('companies', $companies);
if (array_var($_POST, 'process') == 'process') {
try {
DB::beginWork();
active_project()->clearCompanies();
active_project()->clearUsers();
$companies = array(owner_company());
$client_companies = owner_company()->getClientCompanies();
if (is_array($client_companies)) {
$companies = array_merge($companies, $client_companies);
}
// if
foreach ($companies as $company) {
// Company is selected!
if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') {
// Owner company is automaticly included so it does not need to be in project_companies table
if (!$company->isOwner()) {
$project_company = new ProjectCompany();
$project_company->setProjectId(active_project()->getId());
$project_company->setCompanyId($company->getId());
$project_company->save();
}
// if
$users = $company->getUsers();
if (is_array($users)) {
$counter = 0;
foreach ($users as $user) {
$user_id = $user->getId();
$counter++;
if (array_var($_POST, "project_user_{$user_id}") == 'checked') {
$project_user = new ProjectUser();
$project_user->setProjectId(active_project()->getId());
$project_user->setUserId($user_id);
foreach ($permissions as $permission => $permission_text) {
// Owner company members have all permissions
$permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked';
$setter = 'set' . Inflector::camelize($permission);
$project_user->{$setter}($permission_value);
}
// if
$project_user->save();
}
// if
}
// foreach
}
// if
}
// if
}
// foreach
DB::commit();
flash_success(lang('success update project permissions'));
if ($project_init) {
$this->redirectToUrl(active_project()->getEditUrl(active_project()->getOverviewUrl()));
} else {
$this->redirectTo('project_settings', 'users');
}
// if
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error update project permissions'));
$this->redirectTo('project_settings', 'permissions');
}
// try
}
// if
}
示例15: isAccountOwner
/**
* Account owner is user account that was created when company website is created
*
* @param void
* @return boolean
*/
function isAccountOwner()
{
if (is_null($this->is_account_owner)) {
$this->is_account_owner = $this->isMemberOfOwnerCompany() && owner_company()->getCreatedById() == $this->getId();
}
// if
return $this->is_account_owner;
}