Example #1
0
 public function insert()
 {
     try {
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         require_once 'Sitengine/String.php';
         $id = Sitengine_String::createId();
         $data = array();
         $notifyNewUser = $this->_controller->getRequest()->getPost('notifyNewUser');
         if ($notifyNewUser) {
             $password = Sitengine_String::createId(8);
         } else {
             $name = 'password';
             $password = $this->_controller->getRequest()->getPost($name);
             if (Sitengine_Validator::nada($this->_controller->getRequest()->getPost($name))) {
                 $message = $this->_controller->getTranslate()->translate('hintsPasswordRequired');
                 $this->_controller->getStatus()->addHint($name, $message);
             }
         }
         if (!$this->_controller->getPermiso()->getUsersTable()->checkUserModifyData($this->_controller->getStatus(), $this->_controller->getRequest(), $this->_controller->getTranslate())) {
             return null;
         }
         $this->_controller->getFrontController()->getPermiso()->getUsersTable()->handleInsertUploads($id);
         foreach ($fields as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         require_once 'Zend/Date.php';
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['id'] = $id;
         # make names lowercase
         $data['name'] = mb_strtolower($data['name']);
         # encrypt password
         $data['password'] = md5($password);
         $data = array_merge($data, $this->_controller->getFrontController()->getPermiso()->getUsersTable()->getFileData());
         #Sitengine_Debug::print_r($data);
         $insertId = $this->_controller->getFrontController()->getPermiso()->getUsersTable()->insertOrRollback($data);
         if (!$insertId) {
             $error = $this->_controller->getFrontController()->getPermiso()->getUsersTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         if ($notifyNewUser) {
             $this->_sendNotifyNewUserMail($data, $password);
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Permiso/Backend/Users/Exception.php';
         throw new Sitengine_Permiso_Backend_Users_Exception('insert error', $exception);
     }
 }
Example #2
0
 public function insert()
 {
     try {
         $this->_payloads->start();
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         $id = Sitengine_String::createId();
         $data = $this->_controller->getFrontController()->getNewsletterPackage()->getCampaignsTable()->getDefaultPermissionData($this->_controller->getPermiso(), $this->_controller->getFrontController()->getNewsletterPackage()->getOwnerGroup());
         if (!$this->_checkInput()) {
             return null;
         }
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['id'] = $id;
         ### statically set permissions ###
         $ownerGroup = $this->_controller->getFrontController()->getNewsletterPackage()->getOwnerGroup();
         $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($ownerGroup);
         $gid = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS;
         $uid = $this->_controller->getPermiso()->getAuth()->getId();
         $data[Sitengine_Permiso::FIELD_UID] = $uid;
         $data[Sitengine_Permiso::FIELD_GID] = $gid;
         $data[Sitengine_Permiso::FIELD_RAG] = 1;
         $data[Sitengine_Permiso::FIELD_RAW] = 1;
         $data[Sitengine_Permiso::FIELD_UAG] = 1;
         $data[Sitengine_Permiso::FIELD_UAW] = 0;
         $data[Sitengine_Permiso::FIELD_DAG] = 1;
         $data[Sitengine_Permiso::FIELD_DAW] = 0;
         ### statically set permissions ###
         #Sitengine_Debug::print_r($data);
         $insertId = $this->_controller->getFrontController()->getNewsletterPackage()->getCampaignsTable()->insertOrRollback($data);
         if (!$insertId) {
             $error = $this->_controller->getFrontController()->getNewsletterPackage()->getCampaignsTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Newsletter/Backend/Campaigns/Exception.php';
         throw new Sitengine_Newsletter_Backend_Campaigns_Exception('insert error', $exception);
     }
 }
Example #3
0
 public function registerSessionVal(Zend_Session_Namespace $namespace, Sitengine_Controller_Request_Http $request, $param, $ignore = 'noneSelected')
 {
     if (is_null($request->get($param))) {
         $value = isset($namespace->{$param}) ? Sitengine_String::runtimeStripSlashes($namespace->{$param}) : '';
         #print $param.' = null<br />';
     } else {
         $value = $request->get($param);
         $value = $value == $ignore ? '' : $value;
         if ($value != '') {
             $namespace->{$param} = $value;
         } else {
             unset($namespace->{$param});
         }
         #print $param.' = '.$request->get($param).'<br />';
     }
     $this->_data[$param] = array('value' => $value, 'clause' => '', 'element' => '');
 }
Example #4
0
 public function insert()
 {
     try {
         $parentId = $this->_controller->getEntity()->getAncestorId();
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         $id = Sitengine_String::createId();
         $data = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTable()->getDefaultPermissionData($this->_controller->getPermiso(), $this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup());
         if (!$this->_checkInput()) {
             return null;
         }
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $data['id'] = $id;
         $data['parentId'] = $parentId;
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['origin'] = $this->_controller->getFrontController()->getBlogPackage()->getName();
         #Sitengine_Debug::print_r($data);
         $data['approve'] = 1;
         $insertId = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTable()->insertOrRollback($data);
         if (!$insertId) {
             $error = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Posts/Comments/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Posts_Comments_Exception('insert error', $exception);
     }
 }
Example #5
0
 public function insert()
 {
     try {
         $this->_payloads->start();
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         $id = Sitengine_String::createId();
         $data = array();
         if (!$this->_checkInput()) {
             return null;
         }
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['id'] = $id;
         #$data[Sitengine_Permiso::FIELD_OID] = $this->_controller->getPermiso()->getOrganization()->getId();
         #Sitengine_Debug::print_r($data);
         $affectedRows = $this->_controller->getRecord()->insert($data);
         if (!$affectedRows) {
             $error = $this->_controller->getRecord()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Exception('insert error', $exception);
     }
 }
Example #6
0
 public function insert()
 {
     try {
         $groupId = $this->_controller->getEntity()->getAncestorId();
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         require_once 'Sitengine/String.php';
         $id = Sitengine_String::createId();
         $data = array();
         if (!$this->_checkInput()) {
             return null;
         }
         foreach ($fields as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         require_once 'Zend/Date.php';
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['id'] = $id;
         $data['groupId'] = $groupId;
         #Sitengine_Debug::print_r($data);
         $insertId = $this->_controller->getFrontController()->getPermiso()->getMembershipsTable()->insertOrRollback($data);
         if (!$insertId) {
             $error = $this->_controller->getFrontController()->getPermiso()->getMembershipsTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Permiso/Backend/Groups/Members/Exception.php';
         throw new Sitengine_Permiso_Backend_Groups_Members_Exception('insert error', $exception);
     }
 }
Example #7
0
 public function log($source, $action, $code = null, $message = null)
 {
     try {
         /*
         if(
         	!$this->_permiso->getAuth()->hasIdentity() &&
         	($source != 'permiso' && $action != 'login')
         ) {
         	return false;
         }
         */
         require_once 'Sitengine_String.php';
         require_once 'Zend/Date.php';
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data = array('id' => Sitengine_String::createId(), 'uid' => $this->_permiso->getAuth()->getId(), 'name' => $this->_permiso->getAuth()->getIdentity(), 'cdate' => $date->get(Zend_Date::ISO_8601), 'ip' => $_SERVER['REMOTE_ADDR'], 'source' => $source, 'action' => $action, 'code' => $code, 'message' => $message);
         return $this->_database->insert($this->_permiso->getAuditTableName(), $data);
     } catch (Exception $exception) {
         require_once 'Sitengine/Permiso/Exception.php';
         throw new Sitengine_Permiso_Exception('log error', $exception);
     }
 }
Example #8
0
 public function insert()
 {
     try {
         $this->_payloads->start();
         $parentId = $this->_controller->getEntity()->getAncestorId();
         $fields = $this->_getFields();
         $input = $this->_controller->getRequest()->getPost(null);
         $id = Sitengine_String::createId();
         $data = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->getDefaultPermissionData($this->_controller->getPermiso(), $this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup());
         $name = 'file1Original';
         $upload = new Sitengine_Upload($name);
         if (!$upload->isFile()) {
             $message = $this->_controller->getTranslate()->translate('hintsFile1OriginalRequired');
             $this->_controller->getStatus()->addHint($name, $message);
             return null;
         }
         if (!$this->_checkInput()) {
             return null;
         }
         $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->handleInsertUploads($id);
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $data['id'] = $id;
         $data['parentId'] = $parentId;
         ##$data[Sitengine_Permiso::FIELD_OID] = $this->_controller->getPermiso()->getOrganization()->getId();
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data = array_merge($data, $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->getFileData());
         #Sitengine_Debug::print_r($data);
         $insertId = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->insertOrRollback($data);
         if (!$insertId) {
             $error = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Backend/Blogs/Posts/Files/Exception.php';
         throw new Sitengine_Blog_Backend_Blogs_Posts_Files_Exception('insert error', $exception);
     }
 }
Example #9
0
 public function insert($type, $parentId)
 {
     try {
         $this->_payloads->start();
         $fields = $this->_getFields($type);
         $input = $this->_controller->getRequest()->getPost(null);
         $id = Sitengine_String::createId();
         $data = array();
         if ($type == Sitengine_Sitemap::ITEMTYPE_FILE) {
             $this->_checkUpload(true);
         }
         if (!$this->_checkInput($type)) {
             return null;
         }
         $this->_controller->getRecord()->handleInsertUploads($id);
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $data[Sitengine_Record::FIELD_ID] = $id;
         $data['pid'] = $parentId;
         $data['type'] = $type;
         #$data[Sitengine_Permiso::FIELD_OID] = $this->_controller->getPermiso()->getOrganization()->getId();
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         ### statically set permissions ###
         $ownerGroup = $this->_controller->getOwnerGroup();
         $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($ownerGroup);
         $gid = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS;
         $uid = $this->_controller->getPermiso()->getAuth()->getId();
         $data[Sitengine_Permiso::FIELD_UID] = $uid;
         $data[Sitengine_Permiso::FIELD_GID] = $gid;
         $data[Sitengine_Permiso::FIELD_RAG] = 1;
         $data[Sitengine_Permiso::FIELD_RAW] = 1;
         $data[Sitengine_Permiso::FIELD_UAG] = 1;
         $data[Sitengine_Permiso::FIELD_UAW] = 0;
         $data[Sitengine_Permiso::FIELD_DAG] = 1;
         $data[Sitengine_Permiso::FIELD_DAW] = 0;
         ### statically set permissions ###
         $data = array_merge($data, $this->_controller->getRecord()->getFileData());
         #Sitengine_Debug::print_r($data);
         $affectedRows = $this->_controller->getRecord()->insert($data);
         if (!$affectedRows) {
             $error = $this->_controller->getRecord()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Sitemap/Backend/Exception.php';
         throw new Sitengine_Sitemap_Backend_Exception('insert error', $exception);
     }
 }
Example #10
0
 protected function _save(Sitengine_Permiso_Model_Account_Form $form)
 {
     require_once 'Sitengine/Status.php';
     $status = Sitengine_Status::getInstance();
     if (!$form->isValid($_POST)) {
         foreach ($form->getMessages() as $key => $messages) {
             $status->addHint($key, $messages);
         }
         return false;
     }
     if ($this->_getUserRow() === null) {
         $this->_userRow = $this->getPermiso()->getUsersTable()->createRow($form->getValues());
         $this->_getUserRow()->setId(Sitengine_String::createId());
         $this->_getUserRow()->setCdate($this->getPermiso()->getUsersTable()->getNow());
         $this->_getUserRow()->setPassword($this->_makePasswordHash($form->getPasswordVal()));
     } else {
         $password = $form->getPasswordVal() ? $this->_makePasswordHash($form->getPasswordVal()) : $this->_getUserRow()->getPassword();
         $this->_getUserRow()->setFromArray($form->getValues());
         $this->_getUserRow()->setPassword($password);
     }
     try {
         $this->_getUserRow()->setMdate($this->getPermiso()->getUsersTable()->getNow());
         $this->_getUserRow()->setEnabled(1);
         # TODO - a better way for use in other contexts
         $this->_getUserRow()->save();
     } catch (Exception $exception) {
         if ($this->getPermiso()->getUsersTable()->checkModifyException($exception)) {
             throw $exception;
         }
         switch ($this->getPermiso()->getUsersTable()->getError()) {
             case 'nameExists':
                 $hint = self::HINT_NAME_EXISTS;
                 break;
             case 'nicknameExists':
                 $hint = self::HINT_NICKNAME_EXISTS;
                 break;
             default:
                 $hint = self::HINT_UNKNOWN_ERROR;
                 break;
         }
         $message = $this->_getTranslator()->translate($hint);
         $status->addHint($hint, $message);
         return false;
     }
     return true;
 }
Example #11
0
 public static function getHidden($name, $value)
 {
     $value = is_object($value) ? '' : (string) $value;
     $t = '<input';
     $t .= ' name="' . (string) $name . '"';
     $t .= ' value="' . Sitengine_String::html($value) . '"';
     $t .= ' type="hidden"';
     $t .= ' />';
     $t .= "\n";
     return $t;
 }
Example #12
0
 public function getCookie($key = null, $default = null)
 {
     if ($key === null) {
         $in = array();
         foreach ($_COOKIE as $k => $v) {
             $in[$k] = Sitengine_String::gpcStripSlashes($v);
         }
         return $in;
     }
     return isset($_COOKIE[$key]) ? Sitengine_String::gpcStripSlashes($_COOKIE[$key]) : $default;
 }
Example #13
0
 protected function _insertVideoPost($blogId)
 {
     try {
         $this->_payloads->start();
         $input = $this->_controller->getRequest()->getPost(null);
         $fields = $this->_getVideoPostFields();
         $id = Sitengine_String::createId();
         $data = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable()->getDefaultPermissionData($this->_controller->getPermiso(), $this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup());
         if (!$this->_checkVideoPostInput()) {
             return null;
         }
         foreach ($fields[self::FIELDS_ONOFF] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? 1 : 0;
         }
         foreach ($fields[self::FIELDS_NORMAL] as $k => $v) {
             $data[$k] = array_key_exists($k, $input) ? $input[$k] : $v;
         }
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $data['cdate'] = $date->get('YYYY-MM-dd HH:mm:ss', Sitengine_Env::LANGUAGE_EN);
         $data['mdate'] = $data['cdate'];
         $data['id'] = $id;
         $data['blogId'] = $blogId;
         $data['type'] = Sitengine_Blog_Posts_Table::TYPE_VIDEO;
         ##$data[Sitengine_Permiso::FIELD_OID] = $this->_controller->getPermiso()->getOrganization()->getId();
         #Sitengine_Debug::print_r($data);
         $affectedRows = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable()->insertOrRollback($data);
         if (!$affectedRows) {
             $error = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable()->getError();
             if ($error === null) {
                 return null;
             }
             $message = $this->_controller->getTranslate()->translate('hints' . ucfirst($error));
             $this->_controller->getStatus()->addHint('record', $message);
             return null;
         }
         return $data;
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Backend/Blogs/Posts/Exception.php';
         throw new Sitengine_Blog_Backend_Blogs_Posts_Exception('insert error', $exception);
     }
 }
Example #14
0
 protected function _establishValue(Sitengine_Controller_Request_Http $request, $param)
 {
     $value = isset($this->_namespace->{$param}) ? Sitengine_String::runtimeStripSlashes($this->_namespace->{$param}) : null;
     $value = $request->get($param) !== null ? $request->get($param) : $value;
     if (!$value) {
         unset($this->_namespace->{$param});
     } else {
         $this->_namespace->{$param} = $value;
     }
     #print $param.' = '.$value.'<br />';
     return $value;
 }
Example #15
0
 protected function _getMainSection()
 {
     try {
         $elements = array();
         $input = $this->_controller->getRequest()->getPost(null);
         #$valueSort = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT);
         #$valueOrder = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER);
         #$valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable();
         $table->setTranscript($this->_controller->getPreferences()->getTranscript());
         $transcripts = $table->getTranscripts();
         ########################################################################
         #### FILTER INPUT
         ########################################################################
         $fieldsNormal = array('id' => '');
         foreach ($transcripts->get() as $index => $symbol) {
             $fieldsNormal['titleLang' . $index] = '';
             $fieldsNormal['teaserLang' . $index] = '';
         }
         $fieldsOnOff = array('publish' => 1);
         if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) {
             require_once 'Sitengine/Form/TranscriptsPayloads.php';
             $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts);
             $payloads->start($this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAYLOAD_NAME));
             $stored = $this->_controller->getFrontController()->getBlogPackage()->getPostsTable()->complementRow($this->_controller->getEntity()->getRow());
             $data = Sitengine_Controller_Request_Http::filterUpdateDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff, $stored);
             $data = array_merge($stored, $data);
             # set dates to timezone
             /*
             $name = 'cdate';
             $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
             $date->setTimezone($this->_controller->getPreferences()->getTimezone());
             $data[$name]  = $date->get(Zend_Date::DATE_FULL).' ';
             $data[$name] .= $date->get(Zend_Date::TIME_FULL);
             */
             /*
             $name = 'mdate';
             $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
             $date->setTimezone($this->_controller->getPreferences()->getTimezone());
             $data[$name]  = $date->get(Zend_Date::DATE_LONG).' ';
             $data[$name] .= $date->get(Zend_Date::TIME_LONG);
             */
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ID => $stored['id']);
             $query = array();
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_SHARP);
             $queryUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args);
             $queryUpdate .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
             $childActions = $this->_controller->getViewHelper()->getCommentActions($stored['id']);
             $hiddens = array(Sitengine_Env::PARAM_METHOD => Sitengine_Env::METHOD_PUT, Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), Sitengine_Env::PARAM_MDATE => $stored['mdate']);
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ID => $stored['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_SHARP);
             $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $title = $stored['titleLang' . $transcripts->getIndex()];
             $title = $title != '' ? $title : $stored['teaserLang0'];
             $title = $this->_controller->getTranslate()->translate('formquoteviewUpdateTitle') . ' (' . Sitengine_String::truncate($title) . ')';
         } else {
             require_once 'Sitengine/Form/TranscriptsPayloads.php';
             $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts);
             $payloads->start();
             $data = Sitengine_Controller_Request_Http::filterInsertDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff);
             $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup());
             $data[Sitengine_Permiso::FIELD_GID] = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS;
             $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId();
             $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), 'type' => Sitengine_Blog_Posts_Table::TYPE_QUOTE);
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug());
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_NEW);
             $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $title = $this->_controller->getTranslate()->translate('formquoteviewInsertTitle');
         }
         #Sitengine_Debug::print_r($data);
         ########################################################################
         #### ELEMENTS
         ########################################################################
         if ($payloads->isMain()) {
             /*
             if(
             	(!$data['id']) || # on insert
             	(isset($data[Sitengine_Permiso::FIELD_UID]) && $data[Sitengine_Permiso::FIELD_UID]==$this->_controller->getPermiso()->getAuth()->getId()) || # owners ok
             	#$this->_controller->getPermiso()->getUser()->hasSupervisorRights() || # supervisors ok
             	#$this->_controller->getPermiso()->getUser()->hasModeratorRights() # moderators ok
             	$this->_controller->getPermiso()->getDirectory()->userIsMember($this->_controller->getPermiso()->getAuth()->getId(), Sitengine_Permiso::GID_ADMINISTRATORS)
             )
             {
             	$n = Sitengine_Permiso::FIELD_UID;
             	$e = new Sitengine_Form_Element($n, $data[$n]);
             	$e->setClass('viewFormSelect');
             	$e->setId('viewForm'.$n);
             	$users = $this->_controller->getPermiso()->getDirectory()->getAllUsers();
             	$elements[$n] = $e->getSelect($users);
             	
             	$n = Sitengine_Permiso::FIELD_GID;
             	$e = new Sitengine_Form_Element($n, $data[$n]);
             	$e->setClass('viewFormSelect');
             	$e->setId('viewForm'.$n);
             	$groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups();
             	$groups = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsGid')->toArray(), $groups);
             	$elements[$n] = $e->getSelect($groups);
             	
             	$n = Sitengine_Permiso::FIELD_RAG;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             	
             	$n = Sitengine_Permiso::FIELD_RAW;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             	
             	$n = Sitengine_Permiso::FIELD_UAG;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             	
             	$n = Sitengine_Permiso::FIELD_UAW;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             	
             	$n = Sitengine_Permiso::FIELD_DAG;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             	
             	$n = Sitengine_Permiso::FIELD_DAW;
             	$e = new Sitengine_Form_Element($n, '1');
             	$e->setClass('viewFormCheckbox');
             	$e->setId('viewForm'.$n);
             	$elements[$n] = $e->getCheckbox($data[$n]);
             }
             */
             $n = 'publish';
             $e = new Sitengine_Form_Element($n, '1');
             $e->setClass('viewFormCheckbox');
             $e->setId('viewForm' . $n);
             $elements[$n] = $e->getCheckbox($data[$n]);
         }
         $n = 'titleLang' . $payloads->getTranscriptIndex();
         $e = new Sitengine_Form_Element($n, $data[$n]);
         $e->setClass('viewFormInput');
         $e->setId('viewForm' . $n);
         $elements['title'] = $e->getText(40);
         /*
         $n = 'teaserLang'.$payloads->getTranscriptIndex();
         $elements['teaser'] = $this->_makeTextarea($n, $data[$n]);
         */
         $n = 'teaserLang' . $payloads->getTranscriptIndex();
         $e = new Sitengine_Form_Element($n, $data[$n]);
         $e->setClass('viewFormTextarea');
         $e->setId('viewForm' . $n);
         $elements['teaser'] = $e->getTextarea(60, 5);
         ########################################################################
         #### CONTENT PAYLOAD SECTION TITLE
         ########################################################################
         $contentSectionTitle = $this->_controller->getTranslate()->translate('formquoteviewContentSectionTitleDefault');
         if (sizeof($transcripts->get()) > 1) {
             if (!$payloads->isMain()) {
                 $symbol = $payloads->getTranscriptSymbol();
             } else {
                 $symbol = $transcripts->getDefaultSymbol();
             }
             $contentSectionTitle .= ' (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')';
         }
         ########################################################################
         #### PAYLOAD NAV DATA
         ########################################################################
         $payloadNav = array();
         if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) {
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ID => $stored['id']);
             $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getMainName());
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_SHARP);
             $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
             $payloadNav[$payloads->getMainName()] = array('uri' => $uri, 'label' => $this->_controller->getTranslate()->translate('formaudioviewPayloadNavTitleMain'));
             $count = 0;
             foreach ($transcripts->get() as $index => $symbol) {
                 # skip default transcript because all fields are available in the overview
                 if ($count) {
                     $currentPayload = $payloads->getTranscriptNamePrefix() . '_' . $symbol;
                     $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorSlug(), Sitengine_Env::PARAM_ID => $stored['id']);
                     $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $currentPayload);
                     $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_SHARP);
                     $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
                     $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
                     if (sizeof($transcripts->get()) > 1) {
                         $label = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol));
                     } else {
                         $label = $this->_controller->getTranslate()->translate('formaudioviewContentSectionTitleDefault');
                     }
                     $payloadNav[$currentPayload] = array('uri' => $uri, 'label' => $label);
                 }
                 $count++;
             }
         }
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         return array('payloadName' => $payloads->getName(), 'payloadIsMain' => $payloads->isMain(), 'payloadIsDefaultTranscript' => $payloads->isDefaultTranscript(), 'queryUpdate' => isset($queryUpdate) ? $queryUpdate : '', 'title' => $title, 'contentSectionTitle' => $contentSectionTitle, 'inputMode' => $this->_inputMode, 'hiddens' => implode('', $hiddens), 'submitUri' => $submitUri, 'ELEMENTS' => $elements, 'CHILDACTIONS' => isset($childActions) ? $childActions : array(), 'PAYLOADNAV' => $payloadNav, 'DATA' => $data);
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Backend/Blogs/Posts/Exception.php';
         throw new Sitengine_Blog_Backend_Blogs_Posts_Exception('form page error', $exception);
     }
 }
Example #16
0
 public function assignFromList($filename, array $data)
 {
     try {
         # sanitize data
         foreach ($data as $k => $v) {
             if (!preg_match('/^(cdate|mdate|gid|parentId)$/', $k)) {
                 unset($data[$k]);
             }
         }
         $sourcePath = $this->_controller->getTempDir() . '/' . $filename;
         if (!is_writeable($sourcePath) || !is_file($sourcePath)) {
             return 0;
         }
         $id = Sitengine_String::createId();
         $data['id'] = $id;
         #$data[Sitengine_Permiso::FIELD_OID] = $this->_controller->getPermiso()->getOrganization()->getId();
         $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId();
         $data[Sitengine_Permiso::FIELD_RAG] = 1;
         $data[Sitengine_Permiso::FIELD_RAW] = 1;
         $data[Sitengine_Permiso::FIELD_UAG] = 1;
         $data[Sitengine_Permiso::FIELD_UAW] = 0;
         $data[Sitengine_Permiso::FIELD_DAG] = 1;
         $data[Sitengine_Permiso::FIELD_DAW] = 0;
         $data['publish'] = 1;
         $data['titleLang0'] = basename($filename);
         $this->_controller->getRecord()->handleFileImport($id, $sourcePath);
         $data = array_merge($data, $this->_controller->getRecord()->getFileData());
         #Sitengine_Debug::print_r($data);
         return $this->_controller->getRecord()->insertFileImport($data);
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Posts/Files/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Posts_Files_Exception('assign from list error', $exception);
     }
 }
Example #17
0
 public static function printQuery(Zend_Db_Adapter_Abstract $database, $query)
 {
     try {
         $s = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
         $s .= '<html>';
         $s .= '<head>';
         $s .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
         $s .= '</head>';
         $s .= '<body>';
         $statement = $database->prepare($query);
         $statement->execute();
         $result = $statement->fetchAll(Zend_Db::FETCH_ASSOC);
         $s .= "<table width=600 border=1>";
         $s .= "<tr><th colspan=\"2\" align=\"left\" bgcolor=\"#eeeeee\"><h2>Database - Select Query</h2></td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Database Class</nobr></nobr></td><td>" . get_class($database) . "&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Statement Class</nobr></td><td>" . get_class($statement) . "&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Rows</nobr></td><td>" . sizeof($result) . "&nbsp;</td></tr>";
         #$s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Columns</nobr></td><td>".$numCols."&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Query</nobr></td><td>" . Sitengine_String::html($query) . "&nbsp;</td></tr>";
         $s .= "</table><br />";
         $count = 0;
         if (sizeof($result) > 0) {
             $s .= "<table border=1>";
             foreach ($result as $row) {
                 if ($count == 0) {
                     # column index
                     $colCount = 0;
                     $s .= "<tr>";
                     foreach ($row as $k => $v) {
                         $s .= '<th align="left" bgcolor="#eeeeee">' . $colCount++ . '</th>';
                     }
                     $s .= "</tr>";
                     # column names
                     $s .= "<tr>";
                     foreach ($row as $k => $v) {
                         $s .= '<th align="left" bgcolor="#eeeeee">' . Sitengine_String::html($k) . '</th>';
                     }
                     $s .= "</tr>";
                 }
                 $s .= "<tr>";
                 foreach ($row as $k => $v) {
                     $v = mb_substr($v, 0, 100);
                     $s .= '<td>' . Sitengine_String::html($v) . '&nbsp;</td>';
                 }
                 $s .= "</tr>";
                 $count++;
             }
             $s .= "</table><br />";
         }
         # EXPLAIN
         $statement = $database->prepare('EXPLAIN ' . $query);
         $statement->execute();
         $result = $statement->fetchAll(Zend_Db::FETCH_ASSOC);
         $count = 0;
         if (sizeof($result) > 0) {
             $s .= "<table border=1>";
             foreach ($result as $row) {
                 if ($count == 0) {
                     # column names
                     $s .= "<tr>";
                     foreach ($row as $k => $v) {
                         $s .= '<th align="left" bgcolor="#eeeeee">' . Sitengine_String::html($k) . '</th>';
                     }
                     $s .= "</tr>";
                 }
                 $s .= "<tr>";
                 foreach ($row as $k => $v) {
                     $v = mb_substr($v, 0, 100);
                     $s .= '<td>' . Sitengine_String::html($v) . '&nbsp;</td>';
                 }
                 $s .= "</tr>";
                 $count++;
             }
             $s .= "</table><br />";
         }
         $s .= '</body>';
         $s .= '</html>';
         print $s;
     } catch (Exception $exception) {
         $s = "<table width=600 border=1>";
         $s .= "<tr><th colspan=\"2\" align=\"left\" bgcolor=\"#eeeeee\"><h2>Database - Select Query</h2></td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Database Class</nobr></td><td>" . get_class($database) . "&nbsp;</td></tr>";
         #$s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Statement Class</nobr></td><td>".get_class($result)."&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Code</nobr></td><td>" . $exception->getCode() . "&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Error</nobr></td><td>" . $exception->getMessage() . "&nbsp;</td></tr>";
         #$s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Native Code</nobr></td><td>".$this->getNativeErrorCode()."&nbsp;</td></tr>";
         #$s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Native Error</nobr></td><td>".Sitengine_String::html($this->getNativeError())."&nbsp;</td></tr>";
         $s .= "<tr><th valign=\"top\" align=\"left\" bgcolor=\"#eeeeee\"><nobr>Query</nobr></td><td>" . Sitengine_String::html($query) . "&nbsp;</td></tr>";
         $s .= "</table><br />";
         print $s;
     }
 }
Example #18
0
 public function truncate($string, $length = 80, $etc = '...', $breakWords = false, $middle = false)
 {
     require_once 'Sitengine/String.php';
     return Sitengine_String::truncate($string, $length, $etc, $breakWords, $middle);
 }
Example #19
0
 public function html($val)
 {
     require_once 'Sitengine/String.php';
     return Sitengine_String::html($val);
 }