/**
  * Get list data (for flat list).
  */
 function getListRowData()
 {
     global $ilUser, $lng, $ilCtrl;
     include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
     $data = array();
     $sess_cur_bm_folder = "";
     if (isset($_SESSION["ilCurBMFolder"])) {
         $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
     }
     $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
     if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder) && !empty($_SESSION["ilCurBMFolder"])) {
         $ilCtrl->setParameter($this, "curBMFolder", ilBookmarkFolder::_getParentId($sess_cur_bm_folder));
         $data[] = array("img" => ilUtil::getImagePath("icon_cat_s.png"), "alt" => $lng->txt("bmf"), "title" => "..", "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
         $this->setTitle($this->getTitle() . ": " . ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
     }
     foreach ($bm_items as $bm_item) {
         switch ($bm_item["type"]) {
             case "bmf":
                 $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
                 $data[] = array("img" => ilUtil::getImagePath("icon_cat_s.png"), "alt" => $lng->txt("bmf"), "title" => ilUtil::prepareFormOutput($bm_item["title"]), "desc" => ilUtil::prepareFormOutput($bm_item["desc"]), "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"), "target" => "");
                 break;
             case "bm":
                 $data[] = array("img" => ilUtil::getImagePath("spacer.png"), "alt" => $lng->txt("bm"), "title" => ilUtil::prepareFormOutput($bm_item["title"]), "desc" => ilUtil::prepareFormOutput($bm_item["desc"]), "link" => ilUtil::prepareFormOutput($bm_item["target"]), "target" => "_blank");
                 break;
         }
     }
     $this->setData($data);
 }
Exemplo n.º 2
0
 /**
  * Import record
  *
  * @param
  * @return
  */
 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 {
     switch ($a_entity) {
         case "bookmarks":
             break;
         case "bookmark_tree":
             $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]);
             if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") {
                 //echo "<br><br>";
                 //var_dump($a_rec);
                 switch ($a_rec["Type"]) {
                     case "bmf":
                         if ($a_rec["Parent"] > 0) {
                             $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
                             include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
                             $bmf = new ilBookmarkFolder(0, $usr_id);
                             $bmf->setTitle($a_rec["Title"]);
                             $bmf->setParent($parent);
                             $bmf->create();
                             $fold_id = $bmf->getId();
                         } else {
                             $tree = new ilTree($usr_id);
                             $tree->setTableNames('bookmark_tree', 'bookmark_data');
                             $fold_id = $tree->readRootId();
                         }
                         $a_mapping->addMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Child"], $fold_id);
                         break;
                     case "bm":
                         $parent = 0;
                         if ((int) $a_rec["Parent"] > 0) {
                             $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]);
                         } else {
                             return;
                         }
                         if ($parent == 0) {
                             $tree = new ilTree($usr_id);
                             $tree->setTableNames('bookmark_tree', 'bookmark_data');
                             $parent = $tree->readRootId();
                         }
                         //echo "-$parent-";
                         include_once "./Services/Bookmarks/classes/class.ilBookmark.php";
                         $bm = new ilBookmark(0, $usr_id);
                         $bm->setTitle($a_rec["Title"]);
                         $bm->setDescription($a_rec["Description"]);
                         $bm->setTarget($a_rec["Target"]);
                         $bm->setParent($parent);
                         $bm->create();
                         break;
                 }
             }
             break;
     }
 }
 /**
  * creates the bookmarks and folders
  * @param    array            array of objects
  * @param    array            stores the number of created objects
  * @param    folder_id        id where to store the bookmarks
  * @param    start_key        key of the objects array where to start
  * @access    private
  */
 function __importBookmarks(&$objects, &$num_create, $folder_id, $start_key = 0)
 {
     if (is_array($objects[$start_key])) {
         foreach ($objects[$start_key] as $obj_key => $object) {
             switch ($object['type']) {
                 case 'bm':
                     if (!$object["title"]) {
                         continue;
                     }
                     if (!$object["target"]) {
                         continue;
                     }
                     $bm = new ilBookmark();
                     $bm->setTitle($object["title"]);
                     $bm->setDescription($object["description"]);
                     $bm->setTarget($object["target"]);
                     $bm->setParent($folder_id);
                     $bm->create();
                     $num_create['bm']++;
                     break;
                 case 'bmf':
                     if (!$object["title"]) {
                         continue;
                     }
                     $bmf = new ilBookmarkFolder();
                     $bmf->setTitle($object["title"]);
                     $bmf->setParent($folder_id);
                     $bmf->create();
                     $num_create['bmf']++;
                     if (is_array($objects[$obj_key])) {
                         $this->__importBookmarks($objects, $num_create, $bmf->getId(), $obj_key);
                     }
                     break;
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * TODO: drop fields last_update & create_date. redundant data in object_data!
  * saves a new record "user" to database
  * @access	public
  * @param	boolean	user data from formular (addSlashes) or not (prepareDBString)
  */
 function saveAsNew($a_from_formular = true)
 {
     global $ilErr, $ilDB, $ilSetting, $ilUser;
     switch ($this->passwd_type) {
         case IL_PASSWD_PLAIN:
             $pw_field = "passwd";
             if (strlen($this->passwd)) {
                 $pw_value = md5($this->passwd);
             } else {
                 $pw_value = $this->passwd;
             }
             break;
         case IL_PASSWD_MD5:
             $pw_field = "passwd";
             $pw_value = $this->passwd;
             break;
         case IL_PASSWD_CRYPT:
             $pw_field = "i2passwd";
             $pw_value = $this->passwd;
             break;
         default:
             $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. " . $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
     }
     if (!$this->active) {
         $this->setInactivationDate(ilUtil::now());
     }
     $insert_array = array("usr_id" => array("integer", $this->id), "login" => array("text", $this->login), $pw_field => array("text", $pw_value), "firstname" => array("text", $this->firstname), "lastname" => array("text", $this->lastname), "title" => array("text", $this->utitle), "gender" => array("text", $this->gender), "email" => array("text", trim($this->email)), "hobby" => array("text", (string) $this->hobby), "institution" => array("text", $this->institution), "department" => array("text", $this->department), "street" => array("text", $this->street), "city" => array("text", $this->city), "zipcode" => array("text", $this->zipcode), "country" => array("text", $this->country), "sel_country" => array("text", $this->sel_country), "phone_office" => array("text", $this->phone_office), "phone_home" => array("text", $this->phone_home), "phone_mobile" => array("text", $this->phone_mobile), "fax" => array("text", $this->fax), "birthday" => array('date', $this->getBirthday()), "last_login" => array("timestamp", null), "last_update" => array("timestamp", ilUtil::now()), "create_date" => array("timestamp", ilUtil::now()), "referral_comment" => array("text", $this->referral_comment), "matriculation" => array("text", $this->matriculation), "client_ip" => array("text", $this->client_ip), "approve_date" => array("timestamp", $this->approve_date), "agree_date" => array("timestamp", $this->agree_date), "active" => array("integer", (int) $this->active), "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()), "time_limit_until" => array("integer", $this->getTimeLimitUntil()), "time_limit_from" => array("integer", $this->getTimeLimitFrom()), "time_limit_owner" => array("integer", $this->getTimeLimitOwner()), "auth_mode" => array("text", $this->getAuthMode()), "ext_account" => array("text", $this->getExternalAccount()), "profile_incomplete" => array("integer", $this->getProfileIncomplete()), "im_icq" => array("text", $this->im_icq), "im_yahoo" => array("text", $this->im_yahoo), "im_msn" => array("text", $this->im_msn), "im_aim" => array("text", $this->im_aim), "im_skype" => array("text", $this->im_skype), "delicious" => array("text", $this->delicious), "latitude" => array("text", $this->latitude), "longitude" => array("text", $this->longitude), "loc_zoom" => array("integer", (int) $this->loc_zoom), "last_password_change" => array("integer", (int) $this->last_password_change_ts), "im_jabber" => array("text", $this->im_jabber), "im_voip" => array("text", $this->im_voip), 'inactivation_date' => array('timestamp', $this->inactivation_date), 'is_self_registered' => array('integer', (int) $this->is_self_registered));
     $ilDB->insert("usr_data", $insert_array);
     // add new entry in usr_defined_data
     $this->addUserDefinedFieldEntry();
     // ... and update
     $this->updateUserDefinedFields();
     // CREATE ENTRIES FOR MAIL BOX
     include_once "Services/Mail/classes/class.ilMailbox.php";
     $mbox = new ilMailbox($this->id);
     $mbox->createDefaultFolder();
     include_once "Services/Mail/classes/class.ilMailOptions.php";
     $mail_options = new ilMailOptions($this->id);
     $mail_options->createMailOptionsEntry();
     // create personal bookmark folder tree
     include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
     $bmf = new ilBookmarkFolder(0, $this->id);
     $bmf->createNewBookmarkTree();
 }
 /**
  * recursive methode generates bookmark output for export
  *
  * @param	array	node date
  * @param	int		depth of recursion
  * @param	bool	true for recursive export
  * @access	private
  */
 function __parseExport($object, $depth = 1, $recursive = true)
 {
     switch ($object['type']) {
         case 'bm':
             $result .= str_repeat("\t", $depth);
             $result .= '<DT><A HREF="' . ilUtil::prepareFormOutput($object['target']) . '" ';
             $result .= 'ADD_DATE="' . intval(0) . '" ';
             $result .= 'LAST_VISIT="' . intval(0) . '" ';
             $result .= 'LAST_MODIFIED="' . intval(0) . '">';
             $result .= ilUtil::prepareFormOutput($object['title']) . '</A>' . "\n";
             if ($object['description']) {
                 $result .= '<DD>' . ilUtil::prepareFormOutput($object['description']) . "\n";
             }
             break;
         case 'bmf':
             $result .= str_repeat("\t", $depth) . '<DT><H3 ADD_DATE="0">' . ilUtil::prepareFormOutput($object['title']) . '</H3>' . "\n";
             if ($object['description']) {
                 $result .= '<DD>' . ilUtil::prepareFormOutput($object['description']) . "\n";
             }
             $result .= str_repeat("\t", $depth) . '<DL><p>' . "\n";
             if ($recursive) {
                 $depth++;
                 $sub_objects = ilBookmarkFolder::getObjects($object['child']);
                 foreach ($sub_objects as $sub_object) {
                     $result .= ilBookmarkImportExport::__parseExport($sub_object, $depth, $recursive);
                 }
                 $depth--;
             }
             $result .= str_repeat("\t", $depth) . '</DL><p>' . "\n";
             break;
     }
     return $result;
 }