示例#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 ($this->usingSqlite() && $oldName !== null && $item->getName() !== $oldName) {
         $this->db->createCommand()->update($this->getTableName('authitemchild'), array('parent' => $item->getName()), 'parent=:whereName', array(':whereName' => $oldName));
         $this->db->createCommand()->update($this->getTableName('authitemchild'), array('child' => $item->getName()), 'child=:whereName', array(':whereName' => $oldName));
         $this->db->createCommand()->update($this->getTableName('authassignment'), array('itemname' => $item->getName()), 'itemname=:whereName', array(':whereName' => $oldName));
     }
     $this->db->createCommand()->update($this->getTableName('authitem'), 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));
     // extra: manejo de sintaxis.
     //
     //	cuando un CAuthItem se guarda, se asegura que en caso de ser
     //  un item tipo TASK que usa sintaxis de descripcion entonces
     //	vigile el menuitem superior, asignando o desasignando automatica-
     //	-mente a este TASK con las tareas superior.
     if ($item->getType() == CAuthItem::TYPE_TASK) {
         if ($this->isTaskSubMenuItem($item)) {
             // es un submenu de otra tarea $parent
             $parent = $this->getParentMenuAuthItem($item);
             if ($parent != null) {
                 // no es huerfana
                 // a inserta a $item como hija de $parent
                 if (!$this->hasItemChild($parent->name, $item->name)) {
                     $this->addItemChild($parent->name, $item->name);
                 }
             }
         }
     }
 }
示例#2
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));
 }
 /**
  * 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();
 }