コード例 #1
0
 protected function _saveGroups(KDatabaseRowInterface $entity)
 {
     $table = $this->getObject('com://admin/docman.database.table.levels');
     $row = $table->select(array('entity' => $entity->uuid), KDatabase::FETCH_ROW);
     $groups = KObjectConfig::unbox($entity->groups);
     $access = null;
     if (is_array($groups) && count($groups)) {
         sort($groups);
         $row->groups = implode(',', array_map('intval', $groups));
         $row->entity = $entity->uuid;
         if ($row->save()) {
             $access = -1 * $row->id;
         }
     } elseif ($entity->inherit || $groups) {
         if (!$row->isNew()) {
             $row->delete();
         }
         $access = $groups ?: self::INHERIT;
     }
     if ($access !== null) {
         if ($entity->getIdentifier()->name === 'document') {
             $entity->access = $access;
         } else {
             $entity->access_raw = $access;
         }
     }
 }
コード例 #2
0
 public function insertChild(KDatabaseRowInterface $node)
 {
     //Track the parent
     $node->setParent($this);
     //Insert the row in the rowset
     $this->getChildren()->insert($node);
     return $this;
 }
コード例 #3
0
ファイル: document.php プロジェクト: raeldc/nooku-mongodb
 /**
  * Insert a row into the rowset
  *
  * The row will be stored by it's identity_column if set or otherwise by
  * it's object handle.
  *
  * @param  object   A KDatabaseRow object to be inserted
  * @return boolean  TRUE on success FALSE on failure
  */
 public function insert(KDatabaseRowInterface $row)
 {
     if (isset($this->_identity_column)) {
         $handle = $row->{$this->_identity_column};
     } else {
         $handle = $row->getHandle();
     }
     if ($handle) {
         $this->_object_set->offsetSet((string) $handle, $row);
     }
     return true;
 }
コード例 #4
0
 /**
  * Add a row in the rowset
  * 
  * Since joomla user group maps at the time being uses 0 as the value of unregistered users,
  * we override this method as Koowa does not allow 0 keys to be inserted
  *
  * @param  object   A KDatabaseRow object to be inserted
  * @return KDatabaseRowsetAbstract
  */
 public function insert(KDatabaseRowInterface $row)
 {
     if (isset($this->_identity_column)) {
         $handle = $row->{$this->_identity_column};
     } else {
         $handle = $row->getHandle();
     }
     $this->_object_set->offsetSet($handle, $row);
     //Add the columns, only if they don't exist yet
     $columns = array_keys($row->toArray());
     foreach ($columns as $column) {
         if (!in_array($column, $this->_columns)) {
             $this->_columns[] = $column;
         }
     }
     return $this;
 }
コード例 #5
0
ファイル: abstract.php プロジェクト: raeldc/com_learn
 	/**
     * Removes a row
     * 
     * The row will be removed based on it's identity_column if set or otherwise by
     * it's object handle.
     *
     * @param  object   A KDatabaseRow object to be removed
     * @return KDatabaseRowsetAbstract
     */
    public function extract(KDatabaseRowInterface $row)
    {
        if(isset($this->_identity_column)) {
           $handle = $row->{$this->_identity_column};
        } else {
           $handle = $row->getHandle();
        }
        
        if($this->_object_set->offsetExists($handle)) {
           $this->_object_set->offsetUnset($handle);
        }
    
        return $this;
    }
コード例 #6
0
ファイル: abstract.php プロジェクト: raeldc/nooku-mongodb
 /**
  * Table delete method
  *
  * @param  object       A KDatabaseRow object
  * @return bool|integer Returns the number of rows deleted, or FALSE if delete query was not executed.
  */
 public function delete(KDatabaseRowInterface $row)
 {
     //Create commandchain context
     $context = $this->getCommandContext();
     $context->operation = KDatabase::OPERATION_DELETE;
     $context->data = $row;
     $context->name = $this->_name;
     $context->affected = false;
     if ($this->getCommandChain()->run('before.delete', $context) !== false) {
         // TODO: Prepare data, running validation, filters, mappings, etc.
         //$context->data->prepare();
         $query = $this->getQuery();
         if (!$row->isNew()) {
             // TODO: map $row->id to $row->_id. Query with all the unique keys of row.
             $query->where('id', '=', $context->data->id);
             // Convert object to array first
             $data = $context->data->toArray();
             //Execute the update query
             $context->affected = $this->_database->delete($context->name, $query, $data);
             if ((int) $context->affected > 0) {
                 //Reverse apply the column mappings and set the data in the row
                 $context->data->setData($data, false)->setStatus(KDatabase::STATUS_DELETED);
             } else {
                 $context->data->setStatus(KDatabase::STATUS_FAILED);
             }
             //Set the query in the context
             $context->query = $query;
         } else {
             $context->data->setStatus(KDatabase::STATUS_FAILED);
         }
         $this->getCommandChain()->run('after.delete', $context);
     }
     return $context->affected;
 }
コード例 #7
0
ファイル: config.php プロジェクト: kosmosby/medicine-prof
 protected function _saveDocumentPath(KDatabaseRowInterface $row)
 {
     if (!$this->isModified('document_path')) {
         return;
     }
     $translator = $this->getService('translator')->getTranslator($this->getIdentifier());
     $from = $this->getFilesContainer()->path_value;
     $path = trim($this->document_path, '\\/');
     if ($from === $path) {
         return;
     }
     if (!preg_match('#^[0-9A-Za-z_\\-\\/]+$#', $path)) {
         JFactory::getApplication()->enqueueMessage($translator->translate('Document path can only contain letters, numbers, dash or underscore'), 'error');
         return;
     }
     $db = JFactory::getDBO();
     $query = sprintf("SELECT COUNT(*) FROM #__menu WHERE alias = %s", $db->quote($path));
     if ($db->setQuery($query)->loadResult()) {
         JFactory::getApplication()->enqueueMessage($translator->translate('A menu item on your site uses this path as its alias. In order to ensure that your site works correctly, the document path was left unchanged.'), 'error');
         return;
     }
     jimport('joomla.filesystem.folder');
     $row->path = $path;
     if ($row->save()) {
         if (JFolder::move(JPATH_ROOT . '/' . $from, JPATH_ROOT . '/' . $path) !== true) {
             JFactory::getApplication()->enqueueMessage($translator->translate('Changes are saved but you should move existing files manually from folder "%from%" to "%to%" at your site root in order to make existing files visible.', array('%from%' => $from, '%to%' => $path)), 'warning');
         }
     }
 }
コード例 #8
0
ファイル: grid.php プロジェクト: ravenlife/Ninja-Framework
 protected function _createURL(KDatabaseRowInterface $row)
 {
     $option = 'com_' . $row->getIdentifier()->package;
     $view = $row->getIdentifier()->name;
     $url = 'index.php?option=' . $option . '&view=' . $view;
     return $url;
 }