當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Groups::findAll方法代碼示例

本文整理匯總了PHP中Groups::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Groups::findAll方法的具體用法?PHP Groups::findAll怎麽用?PHP Groups::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Groups的用法示例。


在下文中一共展示了Groups::findAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: select_users_or_groups

/**
 * Returns a control to select multiple users or groups
 *
 * @param string $name
 * 		Name for the control
 * @param array $workspaces
 * 		Array of workspaces to choose from. If null the workspaces from the WorkspacePanel will be loaded.
 * @param array $selected
 * 		Array of workspaces selected by default
 * @return string
 * 		HTML for the control
 */
function select_users_or_groups($name = "", $users = null, $selected = null, $id = null)
{
    require_javascript('og/UserGroupPicker.js');
    if (!isset($id)) {
        $id = gen_id();
    }
    $selectedCSV = "";
    if (is_array($selected)) {
        foreach ($selected as $s) {
            if ($s instanceof Project) {
                if ($selectedCSV != "") {
                    $selectedCSV .= ",";
                }
                $selectedCSV .= $s->getId();
            }
        }
    }
    $json = array();
    if (logged_user()->isMemberOfOwnerCompany()) {
        $companies = Companies::findAll(array('order' => 'name ASC'));
    } else {
        $companies = array(owner_company(), logged_user()->getCompany());
    }
    foreach ($companies as $company) {
        $company_users = $company->getUsers();
        if (count($company_users) > 0) {
            $json[] = array('p' => 'users', 't' => 'company', 'id' => 'c' . $company->getId(), 'n' => $company->getName());
            foreach ($company_users as $u) {
                $json[] = array('p' => 'c' . $company->getId(), 't' => 'user', 'g' => $u->isGuest() ? 1 : 0, 'id' => $u->getId(), 'n' => $u->getDisplayName());
            }
        }
    }
    $groups = Groups::findAll(array('order' => 'name ASC'));
    foreach ($groups as $group) {
        $json[] = array('p' => 'groups', 't' => 'group', 'id' => $group->getId(), 'n' => $group->getName());
    }
    $jsonUsers = json_encode($json);
    $output = "<div id=\"{$id}-user-picker\"></div>\n\t\t\t<input id=\"{$id}-field\" type=\"hidden\" value=\"{$selectedCSV}\" name=\"{$name}\"></input>\n\t\t<script>\n\t\tvar userPicker = new og.UserPicker({\n\t\t\trenderTo: '{$id}-user-picker',\n\t\t\tfield: '{$id}-field',\n\t\t\tid: '{$id}',\n\t\t\tusers: {$jsonUsers},\n\t\t\theight: 320,\n\t\t\twidth: 210\n\t\t});\n\t\t</script>\n\t";
    return $output;
}
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:52,代碼來源:application.php

示例2: getGroupsByUser

 /**
  * Returns all groups a user belongs to
  *
  * @param $user_id
  * @return unknown
  */
 static function getGroupsByUser($user_id)
 {
     return Groups::findAll(array('conditions' => array('`id` IN (SELECT `group_id` FROM `' . TABLE_PREFIX . 'group_users` WHERE `user_id` = ?)', $user_id)));
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:10,代碼來源:GroupUsers.class.php

示例3: getAll

 /**
  * Return all registered groups
  *
  * @param void
  * @return array
  */
 static function getAll()
 {
     return Groups::findAll();
     // findAll
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:11,代碼來源:Groups.class.php


注:本文中的Groups::findAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。