예제 #1
0
 /**
  * Insert a new object
  * @see icms_ipf_Handler::insert()
  *
  * @param mod_profile_Regstep $obj object
  * @param bool $force
  * @return bool
  */
 public function insert(&$obj, $force = false)
 {
     if (parent::insert($obj, $force)) {
         if ($obj->getVar('step_save') == 1) {
             return $this->updateAll('step_save', 0, new icms_db_criteria_Item('step_id', $obj->getVar('step_id'), "!="));
         }
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * insert a new object in the database
  *
  * @param object $obj reference to the object
  * @param bool $force whether to force the query execution despite security settings
  * @param bool $checkObject check if the object is dirty and clean the attributes
  * @return bool FALSE if failed, TRUE if already present and unchanged or successful
  */
 public function insert(&$obj, $force = false, $checkObject = true)
 {
     $uservars = $this->getUserVars();
     foreach ($uservars as $var) {
         unset($obj->vars[$var]);
     }
     if (count($obj->vars) == 1) {
         return true;
     }
     return parent::insert($obj, $force, $checkObject);
 }
예제 #3
0
 /**
  * Save a icms_view_block_Object Object
  *
  * Overwrited Method
  *
  * @param unknown_type $obj
  * @param unknown_type $force
  * @param unknown_type $checkObject
  * @param unknown_type $debug
  * @return unknown
  */
 public function insert(&$obj, $force = false, $checkObject = true, $debug = false)
 {
     $new = $obj->isNew();
     $obj->setVar('last_modified', time());
     $obj->setVar('isactive', true);
     if (!$new) {
         $sql = sprintf("DELETE FROM %s WHERE block_id = '%u'", $this->db->prefix('block_module_link'), (int) $obj->getVar('bid'));
         if (false != $force) {
             $this->db->queryF($sql);
         } else {
             $this->db->query($sql);
         }
     } else {
         icms_loadLanguageFile('system', 'blocksadmin', true);
         if ($obj->getVar('block_type') == 'K') {
             $obj->setVar('name', _AM_CLONE);
         } else {
             switch ($obj->getVar('c_type')) {
                 case 'H':
                     $obj->setVar('name', _AM_CUSTOMHTML);
                     break;
                 case 'P':
                     $obj->setVar('name', _AM_CUSTOMPHP);
                     break;
                 case 'S':
                     $obj->setVar('name', _AM_CUSTOMSMILE);
                     break;
                 case 'T':
                     $obj->setVar('name', _AM_CUSTOMNOSMILE);
                     break;
                 default:
                     break;
             }
         }
     }
     $status = parent::insert($obj, $force, $checkObject, $debug);
     // TODO: Make something to no query here... implement IPF for block_module_link
     $page = $obj->getVar('visiblein', 'e');
     if (!empty($page)) {
         if (is_array($obj->getVar('visiblein', 'e'))) {
             foreach ($obj->getVar('visiblein', 'e') as $bmid) {
                 $page = explode('-', $bmid);
                 $mid = $page[0];
                 $pageid = $page[1];
                 $sql = "INSERT INTO " . $this->db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $obj->getVar("bid") . "', '" . (int) $mid . "', '" . (int) $pageid . "')";
                 if (false != $force) {
                     $this->db->queryF($sql);
                 } else {
                     $this->db->query($sql);
                 }
             }
         } else {
             $page = explode('-', $obj->getVar('visiblein', 'e'));
             $mid = $page[0];
             $pageid = $page[1];
             $sql = "INSERT INTO " . $this->db->prefix('block_module_link') . " (block_id, module_id, page_id) VALUES ('" . (int) $obj->getVar("bid") . "', '" . (int) $mid . "', '" . (int) $pageid . "')";
             if (false != $force) {
                 $this->db->queryF($sql);
             } else {
                 $this->db->query($sql);
             }
         }
     }
     return $status;
 }
예제 #4
0
 /**
  * Inserts block position into the database
  *
  * @param object  $obj  the block position object
  * @param bool  $force  force the insertion of the object into the database
  * @param bool  $checkObject  Check the object before insertion
  * @param bool  $debug  turn on debug mode?
  *
  * @return bool  the result of the insert action
  */
 public function insert(&$obj, $force = false, $checkObject = true, $debug = false)
 {
     $obj->setVar('block_default', 0);
     $obj->setVar('block_type', 'L');
     return parent::insert($obj, $force, $checkObject, $debug);
 }
예제 #5
0
 /**
  * Save a profile field in the database
  *
  * @param object $obj reference to the object
  * @param bool $force whether to force the query execution despite security settings
  *
  * @return bool FALSE if failed, TRUE if already present and unchanged or successful
  */
 public function insert(&$obj, $force = false)
 {
     $profile_handler = icms_getmodulehandler('profile', basename(dirname(dirname(__FILE__))), 'profile');
     $obj->cleanVars();
     $defaultstring = "";
     switch ($obj->getVar('field_type')) {
         case "datetime":
         case "date":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
             $obj->setVar('field_maxlength', 10);
             $obj->setVar('field_default', 0);
             break;
         case "longdate":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_MTIME);
             break;
         case "yesno":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_INT);
             $obj->setVar('field_maxlength', 1);
             break;
         case "textbox":
             if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
                 $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
             }
             break;
         case "autotext":
             if ($obj->getVar('field_valuetype') != XOBJ_DTYPE_INT) {
                 $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
             }
             break;
         case "group_multi":
         case "select_multi":
         case "checkbox":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_ARRAY);
             break;
         case "language":
         case "timezone":
         case "theme":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
             break;
         case "dhtml":
         case "textarea":
             $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTAREA);
             break;
     }
     if ($obj->getVar('field_valuetype') == '') {
         $obj->setVar('field_valuetype', XOBJ_DTYPE_TXTBOX);
     }
     $obj->cleanVars();
     if (!in_array($obj->getVar('field_name'), $this->getUserVars())) {
         if ($obj->isNew()) {
             $changetype = "ADD";
         } else {
             $changetype = "CHANGE " . $obj->getVar('field_name', 'n');
         }
         //set type
         switch ($obj->getVar('field_valuetype')) {
             default:
             case XOBJ_DTYPE_ARRAY:
             case XOBJ_DTYPE_EMAIL:
             case XOBJ_DTYPE_TXTBOX:
             case XOBJ_DTYPE_URL:
                 $type = "varchar";
                 // varchars must have a maxlength
                 if (!($obj->getVar('field_maxlength') > 0)) {
                     $obj->setVar('field_maxlength', 255);
                 }
                 if ($obj->getVar('field_default')) {
                     $defaultstring = " DEFAULT " . $this->db->quoteString($obj->cleanVars['field_default']);
                 }
                 break;
             case XOBJ_DTYPE_INT:
                 $type = "int";
                 if ($obj->getVar('field_default')) {
                     $defaultstring = " DEFAULT " . $this->db->quoteString($obj->cleanVars['field_default']);
                 }
                 break;
             case XOBJ_DTYPE_OTHER:
             case XOBJ_DTYPE_TXTAREA:
                 $type = "text";
                 break;
             case XOBJ_DTYPE_MTIME:
                 $type = "date";
         }
         $maxlengthstring = $obj->getVar('field_maxlength') > 0 ? "(" . $obj->getVar('field_maxlength') . ")" : "";
         $notnullstring = " NOT NULL";
         $sql = "ALTER TABLE " . $profile_handler->table . " " . $changetype . " " . $obj->cleanVars['field_name'] . " " . $type . $maxlengthstring . $notnullstring . $defaultstring;
         if (!$this->db->query($sql)) {
             return false;
         }
     }
     //change this to also update the cached field information storage
     $obj->setDirty();
     if (!parent::insert($obj, $force)) {
         return false;
     }
     return true;
 }