Ejemplo n.º 1
0
 /**
  * Create a Repository object from a Database Result
  *
  * The method expects the following schema:
  * CREATE TABLE ajxp_repo ( uuid VARCHAR(33) PRIMARY KEY,
  *                             path VARCHAR(255),
  *                             display VARCHAR(255),
  *                             accessType VARCHAR(20),
  *                             recycle VARCHAR(255) ,
  *                             bcreate BOOLEAN, -- For some reason 'create' is a reserved keyword
  *                             writeable BOOLEAN,
  *                             enabled BOOLEAN );
  *
  * Additionally, the options are stored in a separate table:
  * CREATE TABLE ajxp_repo_options ( oid INTEGER PRIMARY KEY, uuid VARCHAR(33), name VARCHAR(50), val VARCHAR(255) );
  *
  * I recommend an index to increase performance of uuid lookups:
  * CREATE INDEX ajxp_repo_options_uuid_idx ON ajxp_repo_options ( uuid );
  *
  *
  * @param $result Result of a dibi::query() as array
  * @param array|\Result $options_result Result of dibi::query() for options as array
  * @return Repository object
  */
 public function repoFromDb($result, $options_result = array())
 {
     $repo = new Repository($result['id'], $result['display'], $result['accessType']);
     $repo->uuid = $result['uuid'];
     $repo->setOwnerData($result['parent_uuid'], $result['owner_user_id'], $result['child_user_id']);
     $repo->path = $result['path'];
     $repo->create = (bool) $result['bcreate'];
     $repo->writeable = (bool) $result['writeable'];
     $repo->enabled = (bool) $result['enabled'];
     $repo->recycle = "";
     $repo->setSlug($result['slug']);
     if (isset($result['groupPath']) && !empty($result['groupPath'])) {
         $repo->setGroupPath($result['groupPath']);
     }
     $repo->isTemplate = (bool) $result['isTemplate'];
     $repo->setInferOptionsFromParent((bool) $result['inferOptionsFromParent']);
     foreach ($options_result as $k => $v) {
         if (strpos($v, '$phpserial$') !== false && strpos($v, '$phpserial$') === 0) {
             $v = unserialize(substr($v, strlen('$phpserial$')));
         } else {
             if ($k == "META_SOURCES") {
                 $v = unserialize($v);
             }
         }
         $repo->options[$k] = $v;
     }
     if (isset($repo->options["content_filter"]) && is_a($repo->options["content_filter"], "ContentFilter")) {
         $repo->setContentFilter($repo->options["content_filter"]);
     }
     return $repo;
 }
 /**
  * Create a Repository object from a Database Result
  * 
  * The method expects the following schema:
  * CREATE TABLE ajxp_repo ( uuid VARCHAR(33) PRIMARY KEY, 
  * 							path VARCHAR(255), 
  * 							display VARCHAR(255), 
  * 							accessType VARCHAR(20), 
  * 							recycle VARCHAR(255) , 
  * 							bcreate BOOLEAN, -- For some reason 'create' is a reserved keyword
  * 							writeable BOOLEAN, 
  * 							enabled BOOLEAN );
  * 
  * Additionally, the options are stored in a separate table:
  * CREATE TABLE ajxp_repo_options ( oid INTEGER PRIMARY KEY, uuid VARCHAR(33), name VARCHAR(50), val VARCHAR(255) );
  * 
  * I recommend an index to increase performance of uuid lookups:
  * CREATE INDEX ajxp_repo_options_uuid_idx ON ajxp_repo_options ( uuid );
  * 
  * 
  * @param $result Result of a dibi::query() as array
  * @param $options_result Result of dibi::query() for options as array
  * @return Repository object
  */
 function repoFromDb($result, $options_result = array())
 {
     $repo = new Repository($result['id'], $result['display'], $result['accessType']);
     $repo->uuid = $result['uuid'];
     $repo->setOwnerData($result['parent_uuid'], $result['owner_user_id'], $result['child_user_id']);
     $repo->path = $result['path'];
     $repo->create = $result['bcreate'];
     $repo->writeable = $result['writeable'];
     $repo->writeable = true;
     $repo->enabled = $result['enabled'];
     $repo->recycle = "";
     $repo->setSlug($result['slug']);
     $repo->isTemplate = intval($result['isTemplate']) == 1 ? true : false;
     $repo->setInferOptionsFromParent(intval($result['inferOptionsFromParent']) == 1 ? true : false);
     foreach ($options_result as $k => $v) {
         if (strpos($v, '$phpserial$') !== false && strpos($v, '$phpserial$') === 0) {
             $v = unserialize(substr($v, strlen('$phpserial$')));
         } else {
             if ($k == "META_SOURCES") {
                 $v = unserialize($v);
             }
         }
         $repo->options[$k] = $v;
     }
     return $repo;
 }
Ejemplo n.º 3
0
 /**
  * Create a child from this repository if it's a template
  * @param string $newLabel
  * @param array $newOptions
  * @param string $owner
  * @param string $uniqueUser
  * @return Repository
  */
 public function createTemplateChild($newLabel, $newOptions, $owner = null, $uniqueUser = null)
 {
     $repo = new Repository(0, $newLabel, $this->accessType);
     $newOptions["CREATION_TIME"] = time();
     if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
         $newOptions["CREATION_USER"] = AuthService::getLoggedUser()->getId();
     }
     $repo->options = $newOptions;
     $repo->setOwnerData($this->getId(), $owner, $uniqueUser);
     $repo->setInferOptionsFromParent(true);
     return $repo;
 }
Ejemplo n.º 4
0
 /**
  * Create a child from this repository if it's a template
  * @param string $newLabel
  * @param array $newOptions
  * @param string $owner
  * @param string $uniqueUser
  * @return Repository
  */
 public function createTemplateChild($newLabel, $newOptions, $owner = null, $uniqueUser = null)
 {
     $repo = new Repository(0, $newLabel, $this->accessType);
     $repo->options = $newOptions;
     $repo->setOwnerData($this->getId(), $owner, $uniqueUser);
     $repo->setInferOptionsFromParent(true);
     return $repo;
 }