function uploadImage(array $a_upload)
 {
     if (parent::uploadImage($a_upload)) {
         $this->handleQuotaUpdate();
         return true;
     }
     return false;
 }
 protected function doUpdate()
 {
     parent::doUpdate();
     $this->updateActivation();
 }
 /**
  * Build template from portfolio and vice versa
  * 
  * @param ilObjPortfolioBase $a_source
  * @param ilObjPortfolioBase $a_target
  * @param array $a_recipe
  */
 public static function clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe = null)
 {
     global $lng, $ilUser;
     $source_id = $a_source->getId();
     $target_id = $a_target->getId();
     if ($a_source instanceof ilObjPortfolioTemplate && $a_target instanceof ilObjPortfolio) {
         $direction = "t2p";
     } else {
         if ($a_source instanceof ilObjPortfolio && $a_target instanceof ilObjPortfolioTemplate) {
             $direction = "p2t";
         } else {
             return;
         }
     }
     // copy portfolio properties
     $a_target->setPublicComments($a_source->hasPublicComments());
     $a_target->setProfilePicture($a_source->hasProfilePicture());
     $a_target->setFontColor($a_source->getFontColor());
     $a_target->setBackgroundColor($a_source->getBackgroundColor());
     $a_target->setImage($a_source->getImage());
     $a_target->update();
     // banner/images
     $source_dir = $a_source->initStorage($source_id);
     $target_dir = $a_target->initStorage($target_id);
     ilFSStoragePortfolio::_copyDirectory($source_dir, $target_dir);
     // set/copy stylesheet
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $style_id = $a_source->getStyleSheetId();
     if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) {
         $style_obj = ilObjectFactory::getInstanceByObjId($style_id);
         $new_id = $style_obj->ilClone();
         $a_target->setStyleSheetId($new_id);
         $a_target->update();
     }
     // copy pages
     $blog_count = 0;
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioPage::getAllPages($source_id) as $page) {
         $page_id = $page["id"];
         if ($direction == "t2p") {
             $source_page = new ilPortfolioTemplatePage($page_id);
             $target_page = new ilPortfolioPage();
         } else {
             $source_page = new ilPortfolioPage($page_id);
             $target_page = new ilPortfolioTemplatePage();
         }
         $source_page->setPortfolioId($source_id);
         $target_page->setPortfolioId($target_id);
         $page_type = $source_page->getType();
         $page_title = $source_page->getTitle();
         $page_recipe = null;
         if (is_array($a_recipe)) {
             $page_recipe = $a_recipe[$page_id];
         }
         $valid = false;
         switch ($page_type) {
             // blog => blog template
             case ilPortfolioTemplatePage::TYPE_BLOG:
                 if ($direction == "p2t") {
                     $page_type = ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE;
                     $page_title = $lng->txt("obj_blog") . " " . ++$blog_count;
                     $valid = true;
                 }
                 break;
                 // blog template => blog (needs recipe)
             // blog template => blog (needs recipe)
             case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                 if ($direction == "t2p" && is_array($page_recipe)) {
                     $page_type = ilPortfolioPage::TYPE_BLOG;
                     if ($page_recipe[0] == "blog") {
                         switch ($page_recipe[1]) {
                             case "create":
                                 $page_title = self::createBlogInPersonalWorkspace($page_recipe[2]);
                                 $valid = true;
                                 break;
                             case "reuse":
                                 $page_title = $page_recipe[2];
                                 $valid = true;
                                 break;
                             case "ignore":
                                 // do nothing
                                 break;
                         }
                     }
                 }
                 break;
                 // page editor
             // page editor
             default:
                 $target_page->setXMLContent($source_page->copyXmlContent(true));
                 // copy mobs
                 $target_page->buildDom(true);
                 // parse content / blocks
                 $dom = $target_page->getDom();
                 if ($dom instanceof php4DOMDocument) {
                     $dom = $dom->myDOMDocument;
                 }
                 if ($direction == "t2p") {
                     // update profile/consultation hours user id
                     self::updateDomNodes($dom, "//PageContent/Profile", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/ConsultationHours", "User", $ilUser->getId());
                 }
                 // :TODO: skills
                 $valid = true;
                 break;
         }
         if ($valid) {
             // #12038 - update xml from dom
             $target_page->setXMLContent($target_page->getXMLFromDom());
             $target_page->setType($page_type);
             $target_page->setTitle($page_title);
             $target_page->create();
             if ($page_type == ilPortfolioPage::TYPE_PAGE) {
                 $target_page->update();
                 // handle mob usages!
             }
         }
     }
 }
 /**
  * Build template from portfolio and vice versa
  * 
  * @param ilObjPortfolioBase $a_source
  * @param ilObjPortfolioBase $a_target
  * @param array $a_recipe
  */
 public static function clonePagesAndSettings(ilObjPortfolioBase $a_source, ilObjPortfolioBase $a_target, array $a_recipe = null)
 {
     global $lng, $ilUser;
     $source_id = $a_source->getId();
     $target_id = $a_target->getId();
     if ($a_source instanceof ilObjPortfolioTemplate && $a_target instanceof ilObjPortfolio) {
         $direction = "t2p";
     } else {
         if ($a_source instanceof ilObjPortfolio && $a_target instanceof ilObjPortfolioTemplate) {
             $direction = "p2t";
         } else {
             return;
         }
     }
     self::cloneBasics($a_source, $a_target);
     // personal skills
     include_once "Services/Skill/classes/class.ilPersonalSkill.php";
     $pskills = array_keys(ilPersonalSkill::getSelectedUserSkills($ilUser->getId()));
     // copy pages
     $blog_count = 0;
     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
     foreach (ilPortfolioPage::getAllPages($source_id) as $page) {
         $page_id = $page["id"];
         if ($direction == "t2p") {
             $source_page = new ilPortfolioTemplatePage($page_id);
             $target_page = new ilPortfolioPage();
         } else {
             $source_page = new ilPortfolioPage($page_id);
             $target_page = new ilPortfolioTemplatePage();
         }
         $source_page->setPortfolioId($source_id);
         $target_page->setPortfolioId($target_id);
         $page_type = $source_page->getType();
         $page_title = $source_page->getTitle();
         $page_recipe = null;
         if (is_array($a_recipe)) {
             $page_recipe = $a_recipe[$page_id];
         }
         $valid = false;
         switch ($page_type) {
             // blog => blog template
             case ilPortfolioTemplatePage::TYPE_BLOG:
                 if ($direction == "p2t") {
                     $page_type = ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE;
                     $page_title = $lng->txt("obj_blog") . " " . ++$blog_count;
                     $valid = true;
                 }
                 break;
                 // blog template => blog (needs recipe)
             // blog template => blog (needs recipe)
             case ilPortfolioTemplatePage::TYPE_BLOG_TEMPLATE:
                 if ($direction == "t2p" && is_array($page_recipe)) {
                     $page_type = ilPortfolioPage::TYPE_BLOG;
                     if ($page_recipe[0] == "blog") {
                         switch ($page_recipe[1]) {
                             case "create":
                                 $page_title = self::createBlogInPersonalWorkspace($page_recipe[2]);
                                 $valid = true;
                                 break;
                             case "reuse":
                                 $page_title = $page_recipe[2];
                                 $valid = true;
                                 break;
                             case "ignore":
                                 // do nothing
                                 break;
                         }
                     }
                 }
                 break;
                 // page editor
             // page editor
             default:
                 $target_page->setXMLContent($source_page->copyXmlContent(true));
                 // copy mobs
                 $target_page->buildDom(true);
                 // parse content / blocks
                 if ($direction == "t2p") {
                     $dom = $target_page->getDom();
                     if ($dom instanceof php4DOMDocument) {
                         $dom = $dom->myDOMDocument;
                     }
                     // update profile/consultation hours user id
                     self::updateDomNodes($dom, "//PageContent/Profile", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/ConsultationHours", "User", $ilUser->getId());
                     self::updateDomNodes($dom, "//PageContent/MyCourses", "User", $ilUser->getId());
                     // skills
                     $xpath = new DOMXPath($dom);
                     $nodes = $xpath->query("//PageContent/Skills");
                     foreach ($nodes as $node) {
                         $skill_id = $node->getAttribute("Id");
                         // existing personal skills
                         if (in_array($skill_id, $pskills)) {
                             $node->setAttribute("User", $ilUser->getId());
                         } else {
                             if (in_array($skill_id, $a_recipe["skills"])) {
                                 include_once "Services/Skill/classes/class.ilPersonalSkill.php";
                                 ilPersonalSkill::addPersonalSkill($ilUser->getId(), $skill_id);
                                 $node->setAttribute("User", $ilUser->getId());
                             } else {
                                 $page_element = $node->parentNode;
                                 $page_element->parentNode->removeChild($page_element);
                             }
                         }
                     }
                 }
                 $valid = true;
                 break;
         }
         if ($valid) {
             // #12038 - update xml from dom
             $target_page->setXMLContent($target_page->getXMLFromDom());
             $target_page->setType($page_type);
             $target_page->setTitle($page_title);
             $target_page->create();
             if ($page_type == ilPortfolioPage::TYPE_PAGE) {
                 $target_page->update();
                 // handle mob usages!
             }
         }
     }
 }