Exemplo n.º 1
0
 /**
  * @param	CCommonSubAdmin	$newSubadmin
  * @return	bool
  */
 function CreateSubAdmin(&$newSubadmin)
 {
     if ($this->_connector->Execute($this->_commandCreator->CreateSubAdmin($newSubadmin))) {
         $newSubadmin->Id = $this->_connector->GetLastInsertId();
         if (count($newSubadmin->DomainIds) > 0) {
             return $this->_connector->Execute($this->_commandCreator->AddSubAdminDomain($newSubadmin->Id, $newSubadmin->DomainIds));
         }
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * @param Folder $folder
  * @return bool
  */
 function CreateFolder(&$folder)
 {
     if (!$this->_dbConnection->Execute($this->_commandCreator->SelectForCreateFolder($folder))) {
         return false;
     } else {
         $row = $this->_dbConnection->GetNextRecord();
         $folder->FolderOrder = $row && isset($row->norder) ? (int) ($row->norder + 1) : 0;
     }
     if (!$this->_dbConnection->Execute($this->_commandCreator->CreateFolder($folder))) {
         return false;
     }
     $folder->IdDb = $this->_dbConnection->GetLastInsertId();
     if (!$this->_dbConnection->Execute($this->_commandCreator->CreateFolderTree($folder))) {
         return false;
     }
     if (!$this->_dbConnection->Execute($this->_commandCreator->SelectForCreateFolderTree($folder))) {
         return false;
     } else {
         $result = array();
         while ($row = $this->_dbConnection->GetNextRecord()) {
             $IdParent = $row && isset($row->id_parent) ? (int) $row->id_parent : -1;
             $Level = $row && isset($row->folder_level) ? (int) ($row->folder_level + 1) : 0;
             $result[] = array($IdParent, $Level);
         }
         if ($result) {
             foreach ($result as $folderData) {
                 if (!is_array($folderData)) {
                     continue;
                 }
                 $folder->IdParent = $folderData[0];
                 $folder->Level = $folderData[1];
                 if (!$this->_dbConnection->Execute($this->_commandCreator->CreateSelectFolderTree($folder))) {
                     return false;
                 }
             }
         }
     }
     return true;
 }