Пример #1
0
 /**
  * Saves an authorization item to persistent storage.
  * @param CAuthItem $item the item to be saved.
  * @param string $oldName the old item name. If null, it means the item name is not changed.
  */
 public function saveAuthItem($item, $oldName = null)
 {
     if ($oldName !== null && ($newName = $item->getName()) !== $oldName) {
         if (isset($this->_items[$newName])) {
             throw new CException(Yii::t('yii', 'Unable to change the item name. The name "{name}" is already used by another item.', array('{name}' => $newName)));
         }
         if (isset($this->_items[$oldName]) && $this->_items[$oldName] === $item) {
             unset($this->_items[$oldName]);
             $this->_items[$newName] = $item;
             if (isset($this->_children[$oldName])) {
                 $this->_children[$newName] = $this->_children[$oldName];
                 unset($this->_children[$oldName]);
             }
             foreach ($this->_children as &$children) {
                 if (isset($children[$oldName])) {
                     $children[$newName] = $children[$oldName];
                     unset($children[$oldName]);
                 }
             }
             foreach ($this->_assignments as &$assignments) {
                 if (isset($assignments[$oldName])) {
                     $assignments[$newName] = $assignments[$oldName];
                     unset($assignments[$oldName]);
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * isTaskMenuItemChild
  *    detecta si un CAuthItem ($item) es un hijo de otro ($posibleSuperior)
  *  utiliza la sintaxis del atributo Description para detectarlo.
  *
  * @param CAuthItem $item
  * @param CAuthItem $posibleSuperior
  * @access public
  * @return void
  */
 public function isTaskMenuItemChild($item, $posibleSuperior)
 {
     return $this->getTaskParentMenuName($item) == $posibleSuperior->getName();
 }
Пример #3
0
 /**
  * Saves an authorization item to persistent storage.
  * @param CAuthItem $item the item to be saved.
  * @param string $oldName the old item name. If null, it means the item name is not changed.
  */
 public function saveAuthItem($item, $oldName = null)
 {
     if ($this->usingSqlite() && $oldName !== null && $item->getName() !== $oldName) {
         $this->db->createCommand()->update($this->itemChildTable, array('parent' => $item->getName()), 'parent=:whereName', array(':whereName' => $oldName));
         $this->db->createCommand()->update($this->itemChildTable, array('child' => $item->getName()), 'child=:whereName', array(':whereName' => $oldName));
         $this->db->createCommand()->update($this->assignmentTable, array('itemname' => $item->getName()), 'itemname=:whereName', array(':whereName' => $oldName));
     }
     $this->db->createCommand()->update($this->itemTable, array('name' => $item->getName(), 'type' => $item->getType(), 'description' => $item->getDescription(), 'bizrule' => $item->getBizRule(), 'data' => serialize($item->getData())), 'name=:whereName', array(':whereName' => $oldName === null ? $item->getName() : $oldName));
 }
Пример #4
0
 /**
  * Saves an authorization item to persistent storage.
  * @param CAuthItem $item the item to be saved.
  * @param string $oldName the old item name. If null, it means the item name is not changed.
  */
 public function saveAuthItem($item, $oldName = null)
 {
     if ($this->usingSqlite() && $oldName !== null && $item->getName() !== $oldName) {
         $sql = "UPDATE {$this->itemChildTable} SET parent=:newName WHERE parent=:name";
         $command = $this->db->createCommand($sql);
         $command->bindValue(':name', $oldName);
         $command->bindValue(':newName', $item->getName());
         $command->execute();
         $sql = "UPDATE {$this->itemChildTable} SET child=:newName WHERE child=:name";
         $command = $this->db->createCommand($sql);
         $command->bindValue(':name', $oldName);
         $command->bindValue(':newName', $item->getName());
         $command->execute();
         $sql = "UPDATE {$this->assignmentTable} SET itemname=:newName WHERE itemname=:name";
         $command = $this->db->createCommand($sql);
         $command->bindValue(':name', $oldName);
         $command->bindValue(':newName', $item->getName());
         $command->execute();
     }
     $sql = "UPDATE {$this->itemTable} SET name=:newName, type=:type, description=:description, bizrule=:bizrule, data=:data WHERE name=:name";
     $command = $this->db->createCommand($sql);
     $command->bindValue(':type', $item->getType());
     $command->bindValue(':name', $oldName === null ? $item->getName() : $oldName);
     $command->bindValue(':newName', $item->getName());
     $command->bindValue(':description', $item->getDescription());
     $command->bindValue(':bizrule', $item->getBizRule());
     $command->bindValue(':data', serialize($item->getData()));
     $command->execute();
 }