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


PHP Profile_User::can方法代碼示例

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


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

示例1: doSpecificMassiveActions

 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "add_user_group":
             $gu = new Group_User();
             return $gu->doSpecificMassiveActions($input);
         case "force_user_ldap_update":
             if (Session::haveRight("user", "w")) {
                 $ids = array();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             if ($this->fields["authtype"] == Auth::LDAP || $this->fields["authtype"] == Auth::EXTERNAL) {
                                 if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $this->fields["name"]), 1, $this->fields["auths_id"])) {
                                     $res['ok']++;
                                 } else {
                                     $res['ko']++;
                                 }
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             } else {
                 $res['noright']++;
             }
             break;
         case "change_authtype":
             if (!isset($input["authtype"]) || !isset($input["auths_id"])) {
                 return false;
             }
             if (Session::haveRight("user_authtype", "w")) {
                 $ids = array();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $ids[] = $key;
                     }
                 }
                 if (User::changeAuthMethod($ids, $input["authtype"], $input["auths_id"])) {
                     $res['ok']++;
                 } else {
                     $res['ko']++;
                 }
             } else {
                 $res['noright']++;
             }
             break;
         case "add_userprofile":
             $right = new Profile_User();
             if (isset($input['profiles_id']) && $input['profiles_id'] > 0 && isset($input['entities_id']) && $input['entities_id'] >= 0) {
                 $input2 = array();
                 $input2['entities_id'] = $input['entities_id'];
                 $input2['profiles_id'] = $input['profiles_id'];
                 $input2['is_recursive'] = $input['is_recursive'];
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         $input2['users_id'] = $key;
                         if ($right->can(-1, 'w', $input2)) {
                             if ($right->add($input2)) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:80,代碼來源:user.class.php

示例2: Profile

include GLPI_ROOT . "/inc/includes.php";
$profile = new Profile();
$right = new Profile_User();
$user = new User();
if (isset($_POST["add"])) {
    $right->check(-1, 'w', $_POST);
    if ($right->add($_POST)) {
        Event::log($_POST["users_id"], "users", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][61]);
    }
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        if (isset($_POST["item"]) && count($_POST["item"])) {
            foreach ($_POST["item"] as $key => $val) {
                if ($val == 1) {
                    if ($right->can($key, 'w')) {
                        $right->delete(array('id' => $key));
                    }
                }
            }
            if (isset($_POST["entities_id"])) {
                // From entity tab
                Event::log($_POST["entities_id"], "entity", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][62]);
            } else {
                if (isset($_POST["users_id"])) {
                    Event::log($_POST["users_id"], "users", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][62]);
                }
            }
        }
        glpi_header($_SERVER['HTTP_REFERER']);
    } else {
開發者ID:ryukansent,項目名稱:Thesis-SideB,代碼行數:31,代碼來源:profile_user.form.php


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