本文整理汇总了PHP中CMediusers::loadRefsSecondaryFunctions方法的典型用法代码示例。如果您正苦于以下问题:PHP CMediusers::loadRefsSecondaryFunctions方法的具体用法?PHP CMediusers::loadRefsSecondaryFunctions怎么用?PHP CMediusers::loadRefsSecondaryFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMediusers
的用法示例。
在下文中一共展示了CMediusers::loadRefsSecondaryFunctions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadAllModelesFor
/**
* Charge tous les modèles pour une classe d'objets associés à un utilisateur
*
* @param integer $id Identifiant du propriétaire
* @param string $owner Type de propriétaire du modèle: prat, func ou etab
* @param string $object_class Nom de la classe d'objet, optionnel. Doit être un CMbObject
* @param string $type Type de composant, optionnel
* @param bool $fast_edit Inclue les modèles en édition rapide
* @param string $order Ordre de tri de la liste
*
* @return CCompteRendu[][] Par propriétaire: prat => CCompteRendu[], func => CCompteRendu[], etab => CCompteRendu[]
*/
static function loadAllModelesFor($id, $owner = 'prat', $object_class = null, $type = null, $fast_edit = true, $order = "")
{
// Accès aux modèles de la fonction et de l'établissement
$module = CModule::getActive("dPcompteRendu");
$is_admin = $module && $module->canAdmin();
$access_function = $is_admin || CAppUI::conf("compteRendu CCompteRendu access_function");
$access_group = $is_admin || CAppUI::conf("compteRendu CCompteRendu access_group");
$modeles = array();
$modeles["prat"] = array();
if ($access_function) {
$modeles["func"] = array();
}
if ($access_group) {
$modeles["etab"] = array();
}
if (!$id) {
return $modeles;
}
// Clauses de recherche
$modele = new CCompteRendu();
$where = array();
$where["object_id"] = "IS NULL";
if ($object_class) {
$where["object_class"] = "= '{$object_class}'";
}
if ($type) {
$where["type"] = "= '{$type}'";
}
if (!$fast_edit) {
$where["fast_edit"] = " = '0'";
$where["fast_edit_pdf"] = " = '0'";
}
if (!$order) {
$order = "object_class, type, nom";
}
switch ($owner) {
case 'prat':
// Modèle du praticien
$prat = new CMediusers();
if (!$prat->load($id)) {
return $modeles;
}
$prat->loadRefFunction();
$where["user_id"] = "= '{$prat->_id}'";
$where["function_id"] = "IS NULL";
$where["group_id"] = "IS NULL";
$modeles["prat"] = $modele->loadListWithPerms(PERM_READ, $where, $order);
$sec_func = $prat->loadRefsSecondaryFunctions();
foreach ($sec_func as $_func) {
$where["user_id"] = "IS NULL";
$where["function_id"] = "= '{$_func->_id}'";
$where["group_id"] = "IS NULL";
$modeles["func" . $_func->_id] = $modele->loadListWithPerms(PERM_READ, $where, $order);
}
case 'func':
// Modèle de la fonction
if (isset($modeles["func"])) {
if (isset($prat)) {
$func_id = $prat->function_id;
} else {
$func = new CFunctions();
if (!$func->load($id)) {
return $modeles;
}
$func_id = $func->_id;
}
$where["user_id"] = "IS NULL";
$where["function_id"] = "= '{$func_id}'";
$where["group_id"] = "IS NULL";
$modeles["func"] = $modele->loadListWithPerms(PERM_READ, $where, $order);
}
case 'etab':
// Modèle de l'établissement
if (isset($modeles["etab"])) {
$etab_id = CGroups::loadCurrent()->_id;
if ($owner == 'etab') {
$etab = new CGroups();
if (!$etab->load($id)) {
return $modeles;
}
$etab_id = $etab->_id;
} elseif (isset($func)) {
$etab_id = $func->group_id;
} elseif (isset($func_id)) {
$func = new CFunctions();
$func->load($func_id);
$etab_id = $func->group_id;
}
//.........这里部分代码省略.........
示例2: array
$function_id = CValue::get("function_id");
// current user, if no user & no function
if (!$user_id && !$function_id) {
$user_id = CMediusers::get()->_id;
}
$user->load($user_id);
$user->_ref_drawing_cat = $user->loadBackRefs('drawing_category_user');
/** @var CDrawingCategory $_cat */
foreach ($user->_ref_drawing_cat as $_cat) {
$_cat->loadRefsFiles();
}
// function
$functions = array();
if (!$function_id && $user->_id) {
$function_id = $user->function_id;
$functions = $user->loadRefsSecondaryFunctions();
}
$function = new CFunctions();
$function->load($function_id);
$functions[$function->_id] = $function;
foreach ($functions as $_function) {
$_function->_ref_drawing_cat = $_function->loadBackRefs('drawing_category_function');
/** @var CDrawingCategory $_cat */
foreach ($_function->_ref_drawing_cat as $_cat) {
$_cat->loadRefsFiles();
}
}
// group
$group = $function->loadRefGroup();
$group->_ref_drawing_cat = $group->loadBackRefs('drawing_category_group');
/** @var CDrawingCategory $_cat */