Ejemplo n.º 1
0
 public function beforeValidate()
 {
     // Alias
     if ($this->alias) {
         $this->alias = makeAlias($this->alias);
     } else {
         $this->alias = makeAlias($this->question);
     }
     if ($this->isNewRecord) {
         // Check if we already have an alias with those parameters
         if (HelpTopic::model()->exists('alias=:alias', array(':alias' => $this->alias))) {
             $this->addError('alias', at('There is already a help topic with that alias.'));
         }
     } else {
         // Check if we already have an alias with those parameters
         if (HelpTopic::model()->exists('alias=:alias AND id!=:id', array(':id' => $this->id, ':alias' => $this->alias))) {
             $this->addError('alias', at('There is already a help topic with that alias.'));
         }
     }
     return parent::beforeValidate();
 }
extract($_GET);
extract($_POST);
$obj_setting = new common();
$obj = new validation();
/* Get Current Date Time Stamp */
$currentTimestamp = getCurrentTimestamp();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $error = '';
    $obj->add_fields($name, 'req', 'Please Enter Page Title');
    $obj->add_fields($desc, 'req', 'Please Enter Description');
    $error = $obj->validate();
    if ($error) {
        $errorMsg = "<font color='#FF0000' family='verdana' size=2>Please fill all required fields.</font>";
    } else {
        if (trim($slug)) {
            $slug = makeAlias($slug);
        } else {
            $slug = makeAlias($name);
        }
        if (trim($metatitle)) {
            $metatitle = $metatitle;
        } else {
            $metatitle = $name;
        }
        $_SESSION['success_msg'] = 'New page has been saved successfully.';
        $dataArr = array('name' => $name, 'slug' => $slug, 'desc' => $desc, 'publish' => $publish, 'metatitle' => $metatitle, 'metakeyword' => $metakeyword, 'metadescription' => $metadescription, 'can_delete' => $can_delete, 'creation_date' => $currentTimestamp);
        $update_site = $obj_setting->save(TBL_PAGE, $dataArr);
        echo '<script>location.href="' . DEFAULT_ADMIN_URL . '/page";</script>';
        exit;
    }
}