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


PHP Users::instance方法代码示例

本文整理汇总了PHP中Users::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::instance方法的具体用法?PHP Users::instance怎么用?PHP Users::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Users的用法示例。


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

示例1: wiki_replace_link_callback

function wiki_replace_link_callback($matches)
{
    if (count($matches) < 2) {
        return null;
    }
    if ($matches[1] == 'wiki') {
        $rev = Revisions::instance()->getTableName(true);
        $page = Wiki::instance()->getTableName(true);
        $where1 = 'WHERE page_id = ' . $matches[2] . ' AND project_id = ' . active_project()->getId();
        $where2 = 'WHERE id = ' . $matches[2] . ' AND project_id = ' . active_project()->getId();
        $sql = "SELECT page_id, name FROM {$rev} {$where1} ";
        $sql .= "AND revision = ( select revision from {$page} {$where2} )";
        //echo $sql;
        $row = DB::executeOne($sql);
        if (!count($row)) {
            return null;
        }
        $url = get_url($matches[1], 'view', array('id' => $matches[2]));
        $url = str_replace('&amp;', '&', $url);
        return '"' . $row['name'] . '(' . $row['page_id'] . ')":' . $url;
    }
    $user = Users::instance()->getTableName(true);
    $where1 = 'WHERE id = ' . $matches[2];
    $sql = "SELECT id, display_name FROM {$user} {$where1} ";
    echo $sql;
    $row = DB::executeOne($sql);
    if (!count($row)) {
        return null;
    }
    $url = get_url($matches[1], 'card', array('id' => $matches[2]));
    $url = str_replace('&amp;', '&', $url);
    return '"' . $row['display_name'] . '(' . $row['id'] . ')":' . $url;
}
开发者ID:bahmany,项目名称:PythonPurePaperless,代码行数:33,代码来源:wiki.php

示例2: getCompaniesWithUsers

 /**
  * Return all companies that have system users
  *
  * @param void
  * @return array
  */
 static function getCompaniesWithUsers()
 {
     $user_table = Users::instance()->getTableName();
     $companies_table = Companies::instance()->getTableName();
     return Companies::findAll(array('conditions' => array("EXISTS (SELECT `id` FROM {$user_table} WHERE {$user_table}.`company_id` = {$companies_table}.`id` )"), 'order' => '`client_of_id`'));
     // findAll
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:13,代码来源:Companies.class.php

示例3: getUsersByProject

 /**
  * Return all users that are involved in specific project
  *
  * @access public
  * @param Project $project
  * @param string $additional_conditions
  * @return array
  */
 function getUsersByProject(Project $project, $additional_conditions = null)
 {
     $contacts_table = Contacts::instance()->getTableName(true);
     $users_table = Users::instance()->getTableName(true);
     $project_users_table = ProjectUsers::instance()->getTableName(true);
     $users = array();
     $sql = "SELECT {$users_table}.* FROM {$users_table}, {$project_users_table}, {$contacts_table} WHERE ({$users_table}.`id` = {$project_users_table}.`user_id` AND {$contacts_table}.`user_id` = {$users_table}.`id` AND {$project_users_table}.`project_id` = " . DB::escape($project->getId()) . ')';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions})";
     }
     $sql .= " ORDER BY ({$contacts_table}.`display_name`)";
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $users[] = Users::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($users) ? $users : null;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:29,代码来源:ProjectUsers.class.php

示例4: paginate

 /**
  * This function will return paginated result. Result is an array where first element is
  * array of returned object and second populated pagination object that can be used for
  * obtaining and rendering pagination data using various helpers.
  *
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'Users')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return Users::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& Users::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:25,代码来源:BaseUsers.class.php

示例5: manager

 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return Users 
  */
 function manager()
 {
     if (!$this->manager instanceof Users) {
         $this->manager = Users::instance();
     }
     return $this->manager;
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:14,代码来源:BaseUser.class.php

示例6: getAutoAssignUsers

 /**
  * Return users that have auto assign value set to true
  *
  * @access public
  * @param void
  * @return array
  */
 function getAutoAssignUsers()
 {
     $users_table = Users::instance()->getTableName(true);
     $contacts_table = Contacts::instance()->getTableName(true);
     $users = array();
     $sql = "SELECT {$users_table}.* FROM {$users_table}, {$contacts_table} WHERE ({$users_table}.`id` = {$contacts_table}.`user_id` AND {$contacts_table}.`company_id` = " . DB::escape($this->getId()) . " AND {$users_table}.`auto_assign` > " . DB::escape(0) . " )";
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $users[] = Users::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($users) ? $users : null;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:23,代码来源:Company.class.php

示例7: getCompanyUsersByProject

 /**
  * Return users of specific company involeved in specific project
  *
  * @access public
  * @param Company $company
  * @param Project $project
  * @return array
  */
 function getCompanyUsersByProject(Company $company, Project $project)
 {
     $users_table = Users::instance()->getTableName(true);
     return self::getUsersByProject($project, "{$users_table}.`company_id` = " . DB::escape($company->getId()));
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:13,代码来源:ProjectUsers.class.php

示例8: permissions_sql_for_listings

/**
 * Enter description here...
 * assumes manager has one field as PK
 *
 * @param DataManager $manager
 * @param $access_level ACCESS_LEVEL_XX objects that defines which permission is being checked
 * @param string $project_id string that will be compared to the project id while searching project_user table
 * @param int $user_id user whose permissions are being checked
 * @return unknown
 */
function permissions_sql_for_listings(DataManager $manager, $access_level, User $user, $project_id = '`project_id`', $table_alias = null)
{
    if (!$manager instanceof DataManager) {
        throw new Exception("Invalid manager '{$manager}' in permissions helper", -1);
        return '';
    }
    $user_id = $user->getId();
    $oup_tablename = ObjectUserPermissions::instance()->getTableName(true);
    $wo_tablename = WorkspaceObjects::instance()->getTableName(true);
    $users_table_name = Users::instance()->getTableName(true);
    $pu_table_name = ProjectUsers::instance()->getTableName(true);
    if ($user->isGuest() && $access_level == ACCESS_LEVEL_WRITE) {
        return 'false';
    }
    if (isset($table_alias) && $table_alias && $table_alias != '') {
        $object_table_name = $table_alias;
    } else {
        $object_table_name = $manager->getTableName();
    }
    if (!is_numeric($project_id)) {
        $project_id = "{$object_table_name}.{$project_id}";
    }
    $object_id_field = $manager->getPkColumns();
    $object_id = $object_table_name . '.' . $object_id_field;
    $object_manager = get_class($manager);
    $access_level_text = access_level_field_name($access_level);
    $item_class = $manager->getItemClass();
    $is_project_data_object = new $item_class() instanceof ProjectDataObject;
    // permissions for contacts
    if ($manager instanceof Contacts && can_manage_contacts($user)) {
        return 'true';
    }
    if ($manager instanceof Companies && can_manage_contacts($user)) {
        return 'true';
    }
    // permissions for file revisions
    if ($manager instanceof ProjectFileRevisions) {
        $pfTableName = "`" . TABLE_PREFIX . "project_files`";
        return "{$object_table_name}.`file_id` IN (SELECT `id` FROM {$pfTableName} WHERE " . permissions_sql_for_listings(ProjectFiles::instance(), $access_level, $user) . ")";
    }
    // permissions for projects
    if ($manager instanceof Projects) {
        $pcTableName = "`" . TABLE_PREFIX . 'project_users`';
        return "{$object_table_name}.`id` IN (SELECT `project_id` FROM {$pcTableName} `pc` WHERE `user_id` = {$user_id})";
    }
    // permissions for users
    if ($manager instanceof Users) {
        if (logged_user()->isMemberOfOwnerCompany()) {
            return "true";
        } else {
            return "{$object_table_name}.`company_id` = " . owner_company()->getId() . " OR {$object_table_name}.`company_id` = " . logged_user()->getCompanyId();
        }
    }
    $can_manage_object = manager_class_field_name($object_manager, $access_level);
    // user is creator
    $str = " ( `created_by_id` = {$user_id}) ";
    // element belongs to personal project
    /*if($is_project_data_object) // TODO: type of element belongs to a project
    			if (!in_array('project_id', $manager->getColumns())) {
    				$str .= "\n OR ( EXISTS(SELECT * FROM $users_table_name `xx_u`, $wo_tablename `xx_wo`
    				WHERE `xx_u`.`id` = $user_id
    					AND `xx_u`.`personal_project_id` = `xx_wo`.`workspace_id`
    					AND `xx_wo`.`object_id` = $object_id 
    					AND `xx_wo`.`object_manager` = '$object_manager' )) ";
    			} else {
    				$str .= "\n OR ( $project_id = (SELECT `personal_project_id` FROM $users_table_name `xx_u` WHERE `xx_u`.`id` = $user_id)) ";
    			}
    		*/
    // user or group has specific permissions over object
    $group_ids = $user->getGroupsCSV();
    $all_ids = '(' . $user_id . ($group_ids != '' ? ',' . $group_ids : '') . ')';
    $str .= "\n OR ( EXISTS ( SELECT * FROM {$oup_tablename} `xx_oup` \n\t\t\t\tWHERE `xx_oup`.`rel_object_id` = {$object_id} \n\t\t\t\t\tAND `xx_oup`.`rel_object_manager` = '{$object_manager}' \n\t\t\t\t\tAND `xx_oup`.`user_id` IN {$all_ids} \n\t\t\t\t\tAND `xx_oup`.{$access_level_text} = true) )";
    if ($is_project_data_object) {
        // TODO: type of element belongs to a project
        if (!in_array('project_id', $manager->getColumns())) {
            $str .= "\n OR ( EXISTS ( SELECT * FROM {$pu_table_name} `xx_pu`, {$wo_tablename} `xx_wo` \n\t\t\t\tWHERE `xx_pu`.`user_id` IN {$all_ids} \n\t\t\t\t\tAND `xx_pu`.`project_id` = `xx_wo`.`workspace_id`\n\t\t\t\t\tAND `xx_wo`.`object_id` = {$object_id} \n\t\t\t\t\tAND `xx_wo`.`object_manager` = '{$object_manager}'\n\t\t\t\t\tAND `xx_pu`.{$can_manage_object} = true ) ) ";
        } else {
            $str .= "\n OR ( EXISTS ( SELECT * FROM {$pu_table_name} `xx_pu` \n\t\t\t\tWHERE `xx_pu`.`user_id` IN {$all_ids} \n\t\t\t\t\tAND `xx_pu`.`project_id` = {$project_id} \n\t\t\t\t\tAND `xx_pu`.{$can_manage_object} = true ) ) ";
        }
    }
    // check account permissions in case of emails
    if ($manager instanceof MailContents) {
        $maccTableName = MailAccountUsers::instance()->getTableName(true);
        $str .= "\n OR EXISTS(SELECT `id` FROM {$maccTableName} WHERE `account_id` = {$object_table_name}.`account_id` AND `user_id` = {$user_id})";
        if (user_config_option('view deleted accounts emails', null, $user_id)) {
            $str .= "\n OR ((SELECT count(*) FROM `" . TABLE_PREFIX . "mail_accounts` WHERE `id` = {$object_table_name}.`account_id`) = 0) AND `created_by_id` = {$user_id}";
        }
    }
    $hookargs = array('manager' => $manager, 'access_level' => $access_level, 'user' => $user, 'project_id' => $project_id, 'table_alias' => $table_alias);
    Hook::fire('permissions_sql', $hookargs, $str);
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:permissions.php

示例9: getCompanyUsersByWorkspaces

 function getCompanyUsersByWorkspaces(Company $company, $ws)
 {
     $users_table = Users::instance()->getTableName(true);
     return self::getUsersByWorkspaces($ws, "{$users_table}.`company_id` = " . DB::escape($company->getId()));
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:5,代码来源:ProjectUsers.class.php

示例10: getUsers

 public function getUsers($limit, $type = '', $fromId = 0)
 {
     $users = Users::instance();
     return $users->getUsers($this, $limit, $type, $fromId);
 }
开发者ID:hotarucms,项目名称:hotarucms,代码行数:5,代码来源:Hotaru.php

示例11: find

 /**
  * Do a SELECT query over database with specified arguments
  *
  * @access public
  * @param array $arguments Array of query arguments. Fields:
  * 
  *  - one - select first row
  *  - conditions - additional conditions
  *  - order - order by string
  *  - offset - limit offset, valid only if limit is present
  *  - limit
  * 
  * @return one or Users objects
  * @throws DBQueryError
  */
 function find($arguments = null)
 {
     if (isset($this) && instance_of($this, 'UserPasswords')) {
         return parent::find($arguments);
     } else {
         return Users::instance()->find($arguments);
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:24,代码来源:BaseUserPasswords.class.php


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