/**
  * Gets the folder associated with this ObjectFolder object
  * @return Folder - a folder object
  */
 function getFolder()
 {
     if ($this->folder == null) {
         $folderMapper = new FolderMapper();
         $this->folder = $folderMapper->get($this->folderID);
     }
     return $this->folder;
 }
 /**
  * Shows the view for a folder
  */
 function showFolder()
 {
     $folderId = $_REQUEST["childFolderIdHidden"];
     assert($folderId != null);
     $folderMapper = new FolderMapper();
     $folder = $folderMapper->get($folderId);
     $this->showView($folder);
 }
 /**
  * Constructs the IcfTemplating object
  */
 function IcfTemplating($page = "")
 {
     // Load configuration
     $icfConfig = new IcfConfig();
     $this->tpl =& new Savant2();
     // add a template path
     $this->tpl->addPath("template", $icfConfig->cfg_site_beTemplatePath);
     $this->tpl->assign("templatePath", $icfConfig->cfg_site_beTemplateUrl);
     $this->tpl->assign("basePath", $icfConfig->cfg_site_feBaseUrl);
     // multilingual support
     require_once $this->getStringsFile($icfConfig);
     // Session support
     $session = new Session();
     $this->tpl->assign("user", $session->getSessionUser());
     // basic toolbar support
     $toolbarItem = new icfToolbarItem();
     $toolbarItem->setName("exit");
     $toolbarItem->setTitle($text["exit"]);
     $toolbarItem->setUrl("login.php");
     $toolbarItem->setImage("/images/exit.png");
     $toolbarItem->setImage2("/images/exit_f2.png");
     $toolbar = new IcfToolbar();
     $toolbar->addToolbarItem($toolbarItem);
     // Menu support
     $menu = new IcfMenu();
     // Only work it if the session is valid
     $session = new Session();
     if ($session->isValid() == true) {
         $user = $session->getSessionUser();
         // Classes whose objects the user can create
         $baseClassMapper = new BaseClassMapper();
         $classes = $baseClassMapper->findByPermission(Action::ADD_OBJECTS_ACTION(), $user);
         $menu->setContents($classes);
         // The folders
         $folderMapper = new FolderMapper();
         $rootFolder = $folderMapper->getRoot();
         $folderArray = array(0 => $rootFolder);
         $menu->setFolders($folderArray);
     }
     // Set the generated content in the context of this request (available for client pages to change it)
     $this->setText($text);
     $this->setToolbar($toolbar);
     $this->setMenu($menu);
 }
 /**
  * Gets the folder sent in controllerData
  * @return Folder - folder object
  */
 function getFolder()
 {
     $controllerData =& $this->getControllerData();
     $folderId = $controllerData["folderIdSelect"];
     $folderMapper = new FolderMapper();
     $folder = $folderMapper->get($folderId);
     return $folder;
 }
 /**
  * Switches two folders position.
  * @param $folderId int - the folder that is going to switch positions with one that is next to it
  * @param $incremental int - a relative position to the first folder. The folder found in that position
  * switches position with the first folder. It'll be tippically -1 (folderUp) or 1 (folderDown)
  * @access private
  */
 function switchFolders($folderId, $incremental)
 {
     // Get folder
     $folderMapper = new FolderMapper();
     $folder = $folderMapper->get($folderId);
     // Get its parent
     $parentFolder = $folder->getParent();
     // Get its children
     $folderArray = $parentFolder->getChildren();
     // Lookup the folder
     $position = -1000;
     for ($i = 0; $i < count($folderArray); $i++) {
         $arrayFolder = $folderArray[$i];
         if ($folder->getId() == $arrayFolder->getId()) {
             $position = $i;
             break;
         }
     }
     assert($position != -1000);
     $position = $position + $incremental;
     $otherFolder = $folderArray[$position];
     // Switch positions
     $folder->switchPositionWith($otherFolder);
     // Coordinate transaction
     $icfDatabase = new IcfDatabase();
     $conn =& $icfDatabase->dbOpen();
     $conn->StartTrans();
     $folderMapper = new FolderMapper();
     $folderMapper->setConnection($conn);
     // Save objects
     $folderMapper->update($folder);
     $folderMapper->update($otherFolder);
     // Close transaction
     $conn->completeTrans();
     $icfDatabase->dbClose($conn);
 }
Exemple #6
0
 /**
  * Gets the parent folder for this folder
  * @return Folder - folder object, or null, if this folder has no parent
  */
 function getParent()
 {
     // If it has no parent id, it has no parent object also...
     if ($this->getParentId() == null) {
         return null;
     }
     if ($this->parent == null) {
         $folderMapper = new FolderMapper();
         $this->parent = $folderMapper->get($this->getParentId());
     }
     return $this->parent;
 }
Exemple #7
0
        $db = new MySqlDAO();
        $folderMapper = new FolderMapper($db);
        //__construct($folderId, $name, $folderInId, $userId)
        $folder = new Folder($query["folderId"], $query["name"], $query["folderParentId"], $query["userId"]);
        $folderMapper->update($folder);
        die("Folder Renamed Successfully!");
    } else {
        die("Input all params!");
    }
});
$rout_r->map('GET', '/api/folder/delete/', function () {
    session_start();
    global $GLOBALS;
    $query = $GLOBALS['query'];
    if (isset($query["folderId"]) || isset($query["name"]) || isset($query["folderParentId"]) || isset($query["userId"])) {
        $db = new MySqlDAO();
        $folderMapper = new FolderMapper($db);
        $folderMapper->delete($query["folderId"]);
        die("Folder Deleted Successfully!");
    } else {
        die("Input all params!");
    }
});
$rout_r->map('GET', '/api/user/logout/', function () {
    session_start();
    if (isset($_SESSION['userID'])) {
        unset($_SESSION['userID']);
        (new ReportingFramework())->report(['condition' => "success", 'message' => '']);
    }
});
$rout_r->match();
 /**
  * Looks up the folders allowed for the user in the session that can be used to add a new class object
  * @param $class Class whose instance are to be added
  * @return Array - An array that includes for each position other array with: id, title, parentId, closed, open, mode
  */
 function getFolderArray($class, $object = null)
 {
     // Get root folders
     $folderMapper = new FolderMapper();
     $folder = $folderMapper->getRoot();
     $folderArray = array(0 => $folder);
     $allowedFolderArray = array();
     return $this->getFolderArrayRecursive($folderArray, $class, $allowedFolderArray, $object);
 }
 /**
  * Creates a new folder
  * @param $parentFolderId the parent folder id
  */
 function addFolder()
 {
     $controllerData =& $this->collectControlerData();
     $title = $controllerData["titleText"];
     $parentId = $controllerData["parentIdHidden"];
     $position = $controllerData["positionText"];
     $shortDescription = $controllerData["shortDescriptionText"];
     $longDescription = $controllerData["longDescriptionTextarea"];
     $classesIdArray = $controllerData["classesIdSelect"];
     if ($title == null || $title == "") {
         $this->addErrorMessage("title");
     }
     if ($shortDescription == null || $shortDescription == "") {
         $this->addErrorMessage("shortdescription");
     }
     if ($longDescription == null || $longDescription == "") {
         $this->addErrorMessage("longdescription");
     }
     if (count($classesIdArray) <= 0) {
         $this->addErrorMessage("classes");
     }
     if (count($this->controllerMessageArray) > 0) {
         $this->displayAddFolderView();
         return;
     }
     $folderMapper = new FolderMapper();
     $parentFolder = $folderMapper->get($parentId);
     /* @var $parentFolder Folder */
     $folder = new Folder();
     $folder->setTitle($title);
     $folder->setParentId($parentId);
     $folder->setPosition($position);
     $folder->setShortDescription($shortDescription);
     $folder->setLongDescription($longDescription);
     $folderClassesArray = array();
     foreach ($classesIdArray as $classId) {
         $folderClass = new FolderClass();
         $folderClass->setClassID($classId);
         $folderClass->setPosition(1);
         $folderClass->setIsDefault(0);
         array_push($folderClassesArray, $folderClass);
     }
     $folder->setFolderClasses($folderClassesArray);
     $folderService = new FolderService();
     $folderService->save($folder);
     $this->redirectToReferer();
 }