Example #1
0
 /**
  * Add a row to the client space.
  *
  * @param integer $rowID the DB ID of the row to add
  * @param integer $rowTagID the ID attribute of the row tag to add
  * @param integer $index the index position of the row in the CS
  * @return boolean true on success, false on failure.
  * @access public
  */
 function addRow($rowID, $rowTagID, $index)
 {
     //check that another row with same tag ID doesn't exists
     foreach ($this->_rows as $row) {
         if ($row->getTagID() == $rowTagID) {
             return false;
         }
     }
     //row index cannot be more than current rows length
     $sizeofRows = sizeof($this->_rows);
     if ($index > $sizeofRows) {
         $index = $sizeofRows;
     }
     $row = CMS_rowsCatalog::getByID($rowID, $rowTagID);
     if (is_a($row, "CMS_row")) {
         //put row at given index
         $rows = array_slice($this->_rows, 0, $index);
         $after = array_slice($this->_rows, $index);
         $rows[] = $row;
         $this->_rows = array_merge($rows, $after);
         return $row;
     } else {
         $this->raiseError("Row addition was not given a valid rowID");
         return false;
     }
 }
Example #2
0
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_JSON);
//This file is an admin file. Interface must be secure
$view->setSecure();
//CHECKS user has row edition clearance
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) {
    //rows
    CMS_grandFather::raiseError('User has no rights on rows editions');
    $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_NO_RIGHTS_FOR_ROWS));
    $view->show();
}
//load template if any
if (sensitiveIO::isPositiveInteger($rowId)) {
    $row = CMS_rowsCatalog::getByID($rowId);
    if (!$row || $row->hasError()) {
        CMS_grandFather::raiseError('Unknown template row for given Id : ' . $rowId);
        $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_ROW));
        $view->show();
    }
}
$cms_message = '';
switch ($action) {
    case 'properties':
        //Edition
        $creation = false;
        if (!isset($row)) {
            //CREATION
            $row = new CMS_row();
            $creation = true;
Example #3
0
 /**
  * Destroy the module
  *
  * @return void
  * @access public
  */
 function destroy()
 {
     global $cms_user;
     // Check module exists and is polymod
     if (!$this->isDestroyable()) {
         return false;
     }
     // CHECK USED ROWS
     $rowsIds = CMS_rowsCatalog::getByModules(array($this->_codename), false, false);
     //delete all module rows
     foreach ($rowsIds as $rowId) {
         $row = CMS_rowsCatalog::getByID($rowId);
         if (is_object($row)) {
             $row->destroy();
         }
     }
     // TREAT CATEGORIES
     $attrs = array("module" => $this->_codename, "language" => CMS_languagesCatalog::getDefaultLanguage(), "level" => -1, "root" => -1, "cms_user" => $cms_user, "clearanceLevel" => CLEARANCE_MODULE_EDIT, "strict" => false);
     $cats = CMS_moduleCategories_catalog::getAll($attrs);
     if ($cats) {
         foreach ($cats as $cat) {
             // Destroy category
             $cat->destroy();
         }
     }
     // TREAT MODULE & VALIDATIONS RIGHTS
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tmoduleClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t\t\t or moduleClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ",%'\n\t\t ";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['moduleClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set moduleClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     $sql = "\n\t\t\tselect \n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tprofiles\n\t\t\twhere\n\t\t\t\tvalidationClearancesStack_pr like '" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr like '%;" . io::sanitizeSQLString($this->_codename) . ";%'\n\t\t\t\t or validationClearancesStack_pr = '" . io::sanitizeSQLString($this->_codename) . "'\n\t\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $stack = new CMS_stack();
             $stack->setTextDefinition($r['validationClearancesStack_pr']);
             $stack->delAllWithOneKey($this->_codename);
             $qInsert = new CMS_query("update profiles set validationClearancesStack_pr='" . io::sanitizeSQLString($stack->getTextDefinition()) . "' where id_pr='" . $r['id_pr'] . "'");
         }
     }
     //remove module files
     if (CMS_file::deltreeSimulation(PATH_MODULES_FILES_FS . '/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_MODULES_FILES_FS . '/' . $this->_codename, true);
     }
     //remove JS and CSS
     if (is_dir(PATH_JS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_JS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_JS_FS . '/modules/' . $this->_codename, true);
     }
     if (is_dir(PATH_CSS_FS . '/modules/' . $this->_codename) && CMS_file::deltreeSimulation(PATH_CSS_FS . '/modules/' . $this->_codename, true)) {
         CMS_file::deltree(PATH_CSS_FS . '/modules/' . $this->_codename, true);
     }
     $cssFiles = $this->getCSSFiles('', true);
     foreach ($cssFiles as $mediaCssFiles) {
         foreach ($mediaCssFiles as $cssFile) {
             CMS_file::deleteFile(PATH_REALROOT_FS . '/' . $cssFile);
         }
     }
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename));
     CMS_cache::clearTypeCache('polymod');
     // Destroy module
     return parent::destroy();
 }
Example #4
0
 /**
  * Import module from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  * 		array(
  * 				module	=> false|true : the module to create rows (required)
  * 				create	=> false|true : create missing objects (default : true)
  * 				update	=> false|true : update existing objects (default : true)
  * 				files	=> false|true : use files from PATH_TMP_FS (default : true)
  * 			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rows importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rows importation : ' . $params['module'] . "\n";
         return false;
     }
     $return = true;
     foreach ($data as $rowDatas) {
         $importType = '';
         if (isset($rowDatas['uuid']) && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) {
             //row already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $row = CMS_rowsCatalog::getByID($id);
                 $importType = ' (Update)';
             }
         } else {
             //create new row if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //create row
                 $row = new CMS_row();
                 $importType = ' (Creation)';
             }
         }
         if (isset($row)) {
             if ($row->fromArray($rowDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Row ' . $row->getLabel() . ' successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of row ' . $rowDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }