/**
  * Get styles
  *
  * @param
  * @return
  */
 function getStyles()
 {
     global $styleDefinition;
     $all_styles = ilStyleDefinition::getAllSkinStyles();
     // get all user assigned styles
     $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
     // output "other" row for all users, that are not assigned to
     // any existing style
     $users_missing_styles = 0;
     foreach ($all_user_styles as $style) {
         if (!isset($all_styles[$style])) {
             $style_arr = explode(":", $style);
             $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
         }
     }
     if ($users_missing_styles > 0) {
         $all_styles["other"] = array("title" => $this->lng->txt("other"), "id" => "other", "template_id" => "", "style_id" => "", "template_name" => "", "style_name" => "", "users" => $users_missing_styles);
     }
     $this->setData($all_styles);
 }
Exemplo n.º 2
0
 /**
  * Miscellaneous
  * @group IL_Init
  */
 public function testMiscellaneous()
 {
     $value = "";
     include_once "./Services/User/classes/class.ilObjUser.php";
     ilObjUser::_getNumberOfUsersForStyle("default", "delos");
     ilObjUser::_getAllUserAssignedStyles();
     ilObjUser::_moveUsersToStyle("default", "delos", "default", "delos");
     $this->assertEquals("", $value);
 }
 /**
  * save skin and style settings
  */
 function saveStyleSettingsObject()
 {
     global $styleDefinition, $ilCtrl;
     // check if one style is activated
     if (count($_POST["st_act"]) < 1) {
         $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
     }
     //set default skin and style
     if ($_POST["default_skin_style"] != "") {
         $sknst = explode(":", $_POST["default_skin_style"]);
         if ($this->ilias->ini->readVariable("layout", "style") != $sknst[1] || $this->ilias->ini->readVariable("layout", "skin") != $sknst[0]) {
             $this->ilias->ini->setVariable("layout", "skin", $sknst[0]);
             $this->ilias->ini->setVariable("layout", "style", $sknst[1]);
         }
         $this->ilias->ini->write();
     }
     // check if a style should be deactivated, that still has
     // a user assigned to
     $all_styles = ilStyleDefinition::getAllSkinStyles();
     foreach ($all_styles as $st) {
         if (!isset($_POST["st_act"][$st["id"]])) {
             if (ilObjUser::_getNumberOfUsersForStyle($st["template_id"], $st["style_id"]) > 1) {
                 $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
             } else {
                 ilObjStyleSettings::_deactivateStyle($st["template_id"], $st["style_id"]);
             }
         } else {
             ilObjStyleSettings::_activateStyle($st["template_id"], $st["style_id"]);
         }
     }
     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     $ilCtrl->redirect($this, "editSystemStyles");
 }
 /**
  * Get all skins/styles
  *
  * @param
  * @return
  */
 public static function getAllSkinStyles()
 {
     global $styleDefinition;
     $all_styles = array();
     $templates = $styleDefinition->getAllTemplates();
     foreach ($templates as $template) {
         // get styles definition for template
         $styleDef = new ilStyleDefinition($template["id"]);
         $styleDef->startParsing();
         $styles = $styleDef->getStyles();
         foreach ($styles as $style) {
             $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
             // default selection list
             $all_styles[$template["id"] . ":" . $style["id"]] = array("title" => $styleDef->getTemplateName() . " / " . $style["name"], "id" => $template["id"] . ":" . $style["id"], "template_id" => $template["id"], "style_id" => $style["id"], "template_name" => $styleDef->getTemplateName(), "substyle" => $style["substyle"], "style_name" => $style["name"], "users" => $num_users);
         }
     }
     return $all_styles;
 }