Example #1
0
 function __construct()
 {
     $this->__table = 'code_caller';
     $this->form_required_fields[] = 'content';
     $this->_order_by = 'cms_headline';
     parent::__construct();
 }
 /**
  * insert_audit_trail - This is only for timed_remove so that we don't 
  * 	lose the audit_trail.
  * Refactor: Duplication of audit_trail_controller->insert();
  *
  * @param	array 	Required params - asset, asset_id, action_taken
  * @return 	void
  **/
 function insert_audit_trail($params = array())
 {
     if (empty($params)) {
         return false;
     }
     $required_params = array('asset', 'asset_id', 'action_taken');
     foreach ($required_params as $param) {
         if (!isset($params[$param])) {
             return false;
         }
     }
     $model =& NModel::factory($this->name);
     // apply fields in the model
     $fields = $model->fields();
     foreach ($fields as $field) {
         $model->{$field} = isset($params[$field]) ? $params[$field] : null;
     }
     $model->user_id = $this->website_user_id;
     $model->ip = NServer::env('REMOTE_ADDR');
     if (in_array('cms_created', $fields)) {
         $model->cms_created = $model->now();
     }
     if (in_array('cms_modified', $fields)) {
         $model->cms_modified = $model->now();
     }
     // set the user id if it's applicable and available
     if (in_array('cms_modified_by_user', $fields)) {
         $model->cms_modified_by_user = $this->website_user_id;
     }
     $model->insert();
 }
Example #3
0
 function __construct()
 {
     $this->__table = 'workflow_group';
     $this->setHeadline('workflow_title');
     $this->_order_by = 'id';
     parent::__construct();
 }
 function delete($parameter)
 {
     if (empty($parameter)) {
         $this->redirectTo(array('dashboard'));
     }
     // load the model layer with info
     $model =& NModel::factory($this->name);
     if (!$model) {
         $this->redirectTo(array('dashboard'));
     }
     if ($model->get($parameter)) {
         // if the content record is flagged with cms_draft=1, then the content has never been published and should be deleted altogether
         $content_model =& NModel::factory($model->asset);
         if ($content_model && $content_model->get($model->asset_id) && $content_model->cms_draft == 1) {
             $content_model->delete();
         }
         unset($content_model);
         if (defined('SITE_AUDIT_TRAIL') && SITE_AUDIT_TRAIL) {
             // audit trail before delete so we don't lose the values
             $audit_trail =& NController::factory('audit_trail');
             $audit_trail->insert(array('asset' => $this->name, 'asset_id' => $model->{$model->primaryKey()}, 'action_taken' => AUDIT_ACTION_DRAFT_DELETE));
             unset($audit_trail);
         }
         $model->delete();
         if (isset($this->params['_referer']) && $this->params['_referer']) {
             header('Location:' . urldecode($this->params['_referer']));
             exit;
         }
         $this->postProcessForm($model->toArray());
         $this->flash->set('notice', 'Draft deleted.');
     }
     $this->redirectTo(array('dashboard'));
 }
 function displayEditStatus($items)
 {
     $time_now = time();
     foreach ($items as $item) {
         $time_diff = $time_now - $item['timestamp'];
         // Grab information about the person editing.
         $user_info = NModel::factory('cms_auth');
         $user_info->id = $item['user_id'];
         if ($user_info->find()) {
             while ($user_info->fetch()) {
                 $name = $user_info->real_name;
                 $email = $user_info->email;
             }
         }
         unset($cms_auth);
         // Check to see if you're the one editing.
         $auth = new NAuth();
         $current_user_id = $auth->currentUserID();
         unset($auth);
         // Output the item.
         if ($current_user_id == $item['user_id']) {
             print '<div id="actiontrack">You have been editing this record for ' . $time_diff . ' seconds.</div>';
         } else {
             print '<div id="actiontrack"><a href="mailto:' . $email . '">' . $name . '</a> was editing this item ' . $time_diff . ' seconds ago.</div>';
         }
     }
 }
 function function_assign_home_children($params, &$view)
 {
     $page_model = NModel::factory('page');
     $conditions = "parent_id = 1 AND visible = 1 AND active = 1";
     $page_model->find(array("conditions" => $conditions));
     $view->assign('home_children', $page_model->fetchAll(true));
 }
 function __construct()
 {
     $this->__table = 'page_template_containers';
     $this->setHeadline('container_name');
     $this->form_elements['page_template_id'] = array('foreignkey', 'page_template_id', 'Page Template:', array('model' => 'page_template', 'headline' => 'template_name', 'addEmptyOption' => false));
     parent::__construct();
 }
Example #8
0
 function __construct()
 {
     $this->__table = 'bio';
     $this->_order_by = 'cms_headline';
     $this->form_elements['image'] = array('cms_file', 'image', 'Image <small>80x80</small>');
     parent::__construct();
 }
Example #9
0
 function __construct()
 {
     $this->__table = 'cms_asset_info';
     $this->_order_by = 'cms_asset_info.asset_name';
     $this->setHeadline('asset_name');
     parent::__construct();
 }
 function __construct()
 {
     $this->__table = 'cms_asset_template';
     $this->_order_by = $this->__table . '.asset';
     $this->setHeadline('asset');
     $this->form_elements['page_template_container_id'] = array('foreignkey', 'page_template_container_id', 'Container:', array('model' => 'page_template_containers', 'headline' => 'container_name', 'addEmptyOption' => false));
     parent::__construct();
 }
Example #11
0
 function __construct()
 {
     $this->__table = 'news_item';
     $this->form_field_attributes['description'] = array('class' => 'ckeditor');
     $this->_order_by = 'release_date DESC';
     $this->viewlist_fields = array('release_date', 'cms_headline', 'link');
     parent::__construct();
 }
Example #12
0
 function __construct()
 {
     $this->__table = 'poll';
     $this->form_required_fields[] = 'question_count';
     $this->form_elements['cms_headline'] = array('text', 'cms_headline', 'Question');
     $this->order_by = 'active DESC, id DESC';
     parent::__construct();
 }
Example #13
0
 function toArray()
 {
     $ret = parent::toArray();
     if (is_array($ret) && count($ret) && isset($this->setting_var)) {
         $ret['setting_var'] = $this->setting_var;
     }
     return $ret;
 }
Example #14
0
 function __construct()
 {
     $this->__table = 'redirect';
     $this->form_ignore_fields[] = 'count';
     $this->not_connectable = true;
     $this->form_rules[] = array('url', 'This is not a unique url', 'callback', array(&$this, 'validate_url'));
     parent::__construct();
 }
Example #15
0
 function __construct()
 {
     $this->__table = 'workflow';
     $this->form_ignore_fields = array('page_id', 'page_content_id', 'workflow_group_id', 'asset', 'asset_id', 'action', 'draft', 'submitted', 'parent_workflow', 'completed');
     $this->form_elements['approved'] = array('select', 'workflow_approve', 'Approval', array('1' => 'Approve', '0' => 'Decline'));
     $this->form_field_options['timed_start'] = array('addEmptyOption' => true);
     $this->form_field_options['timed_end'] = array('addEmptyOption' => true);
     parent::__construct();
 }
Example #16
0
 function __construct()
 {
     $this->__table = 'masthead';
     $this->form_elements['image'] = array('cms_file', 'image', 'Image');
     $this->form_required_fields[] = 'cms_headline';
     $this->_order_by = 'cms_headline';
     $this->search_field = 'cms_headline';
     parent::__construct();
 }
Example #17
0
 function __construct()
 {
     $this->__table = 'youtube';
     $this->form_required_fields[] = 'embed_html';
     $this->form_elements['thumbnail_image'] = 'cms_file';
     $align_classes = array('default' => "Default", 'left' => "Left", 'right' => "Right", 'center' => "Center");
     $this->form_elements['align'] = array('select', 'align', 'Align', $align_classes);
     parent::__construct();
 }
 function __construct()
 {
     $this->__table = 'media_element';
     // set up form
     $this->form_required_fields[] = 'media_file';
     $this->form_required_fields[] = 'link_title';
     $this->form_elements['media_file'] = array('cms_file', 'media_file', 'Media File');
     $this->_order_by = 'cms_headline';
     parent::__construct();
 }
Example #19
0
 function __construct()
 {
     $this->__table = 'workflow_users';
     $this->_order_by = 'workflow_group_id, cms_created DESC';
     parent::__construct();
     // load the workgroup constants
     include_once BASE_DIR . '/app/controllers/workflow_group_controller.php';
     $this->form_elements['workflow_group_id'] = array('foreignkey', 'workflow_group_id', 'Workflow Group', array('model' => 'workflow_group', 'headline' => 'workflow_title', 'addEmptyOption' => true));
     $this->form_elements['user_id'] = array('foreignkey', 'user_id', 'User', array('model' => 'cms_auth', 'headline' => 'real_name', 'addEmptyOption' => true));
     $this->form_elements['role'] = array('select', 'role', 'Role', array('' => 'Select...', WORKFLOW_ROLE_AUTHOR => 'Author', WORKFLOW_ROLE_EDITOR => 'Editor', WORKFLOW_ROLE_APPROVER => 'Approver'));
     $this->form_required_fields = array('workflow_group_id', 'user_id', 'role');
 }
Example #20
0
 function __construct()
 {
     $this->__table = 'body_image';
     $this->form_elements['small_image'] = array('cms_file', 'small_image', 'Small Image');
     $this->form_elements['large_image'] = array('cms_file', 'large_image', 'Large Image');
     $this->form_elements['align'] = array('select', 'align', 'Align', array('default' => 'Default', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'));
     $this->form_required_fields = array('small_image');
     $this->_order_by = 'cms_headline';
     $this->resize_to_width = 800;
     $this->resize_to_height = 0;
     parent::__construct();
 }
Example #21
0
 function __construct()
 {
     $this->__table = 'text';
     // $this->form_required_fields[] = 'content';
     $this->form_elements['content'] = array('textarea', 'content', 'Content', array('class' => 'ckeditor'));
     $this->form_elements['style_class'] = array('select', 'style_class', 'Style', self::style_classes());
     $this->_order_by = 'cms_headline';
     // You can set this to search a database field.
     $this->search_field = 'content';
     // If you want paging off at all times.
     //$this->paging = 0;
     parent::__construct();
 }
 function getPTIFromId($id)
 {
     $model =& NModel::factory($this->name);
     $model->id = $id;
     if ($model->find()) {
         while ($model->fetch()) {
             $result = $model->toArray();
         }
         $page_template_id = $result['page_template_id'];
     }
     unset($model);
     return $page_template_id;
 }
 public static function forGroup($group)
 {
     if (!$group) {
         throw new Exception("Group not specified", 1);
     }
     $model = NModel::factory('password');
     $conditions = array('conditions' => "cms_headline = '{$group}'");
     if ($model->find($conditions)) {
         $model->fetch();
     } else {
         throw new Exception("Invalid password group: {$group}", 1);
     }
     return $model;
 }
Example #24
0
 /**
  * uniqueUsername - Make sure that the username is unique.
  *
  * @param	string	The username to check.
  * @return 	boolean
  **/
 function uniqueUsername($value)
 {
     $id = $this->{$this->primaryKey()};
     $model =& NModel::factory($this->__table);
     if ($model) {
         $conditions = $id ? $model->primaryKey() . '!=' . $id : '';
         $model->username = $value;
         if ($model->find(array('conditions' => $conditions))) {
             unset($model);
             return false;
         }
     }
     unset($model);
     return true;
 }
Example #25
0
 /**
  * Class Constructor
  *
  * the constructor of the class. sets the table and field variables
  * as well as the root_node
  *
  * @access	public
  * @author	Tim Glen <*****@*****.**>
  * @param 	int $id the table id to retrieve
  * @param 	string $orderby table fields by which to order the result
  * @return 	null
  */
 function __construct()
 {
     parent::__construct();
     if (defined('TREE_CACHING') && TREE_CACHING == false || false == ($nodes = NCache::getMenu())) {
         $pk = $this->primaryKey();
         $model = clone $this;
         $model->reset();
         if ($model->find()) {
             while ($model->fetch()) {
                 $this->nodes[$model->{$pk}] = $model->toArray();
             }
         }
         unset($model);
         if (defined('TREE_CACHING') && TREE_CACHING != false) {
             NCache::createMenu($this->nodes);
         }
     } else {
         $this->nodes =& $nodes;
     }
 }
Example #26
0
 function searchFieldListSelect($params)
 {
     $asset = $params['asset'] ? $params['asset'] : null;
     $searched_field = $params['searched_field'] ? $params['searched_field'] : null;
     if (isset($searched_field)) {
         $searched_field = str_replace(" ", "_", strtolower($searched_field));
     }
     $model = NModel::factory($asset);
     $fields = $model->fields();
     // Remove a bunch of fields if you're not an admin - makes it a little bit simpler.
     $auth = new NAuth();
     $current_user_level = $auth->getAuthData('user_level');
     unset($auth);
     // Preload for the search_field default.
     $acon = NController::factory('asset');
     $select = 'Search Field: <select name="search_field">';
     foreach ($fields as $field) {
         if ($current_user_level < N_USER_ADMIN) {
             if (in_array($field, $this->admin_only_fields)) {
                 continue;
             }
         }
         $select .= '<option value="' . $field . '"';
         if (isset($searched_field) && $searched_field == $field) {
             $select .= ' selected="selected"';
         } elseif (isset($model->search_field) && $field == $model->search_field && !$searched_field) {
             $select .= ' selected="selected"';
         } elseif (!isset($model->search_field) && $field == $acon->search_field && !$searched_field) {
             $select .= ' selected="selected"';
         }
         $select .= '>' . ucwords(str_replace('_', ' ', $field)) . '</option>';
     }
     $select .= '</select>';
     unset($model);
     unset($acon);
     print $select;
 }
Example #27
0
 function test_getFieldType_should_return_proper_types()
 {
     $model =& NModel::singleton('test_sample');
     $varchar = $model->getFieldType('the_varchar');
     $this->assertTrue($varchar == N_DAO_STR || $varchar == N_DAO_STR + N_DAO_NOTNULL);
     $text = $model->getFieldType('the_text');
     $this->assertTrue($text == N_DAO_STR + N_DAO_TXT || $text == N_DAO_STR + N_DAO_TXT + N_DAO_NOTNULL);
     $blob = $model->getFieldType('the_blob');
     $this->assertTrue($blob == N_DAO_BLOB || $blob == N_DAO_BLOB + N_DAO_NOTNULL);
     $tinyint = $model->getFieldType('the_tinyint');
     $this->assertTrue($tinyint == N_DAO_INT + N_DAO_BOOL || $tinyint == N_DAO_INT + N_DAO_BOOL + N_DAO_NOTNULL);
     $int = $model->getFieldType('the_int');
     $this->assertTrue($int == N_DAO_INT || $int == N_DAO_INT + N_DAO_NOTNULL);
     $float = $model->getFieldType('the_float');
     $this->assertTrue($float == N_DAO_FLOAT || $float == N_DAO_FLOAT + N_DAO_NOTNULL);
     $datetime = $model->getFieldType('the_datetime');
     $this->assertTrue($datetime == N_DAO_DATE + N_DAO_TIME || $datetime == N_DAO_DATE + N_DAO_TIME + N_DAO_NOTNULL);
     $date = $model->getFieldType('the_date');
     $this->assertTrue($date == N_DAO_DATE || $date == N_DAO_DATE + N_DAO_NOTNULL);
     $time = $model->getFieldType('the_time');
     $this->assertTrue($time == N_DAO_TIME || $time == N_DAO_TIME + N_DAO_NOTNULL);
     $year = $model->getFieldType('the_year');
     $this->assertTrue($year == N_DAO_INT + N_DAO_DATE || $year == N_DAO_INT + N_DAO_DATE + N_DAO_NOTNULL);
 }
 function checkAssetContainerUsage($asset, $container_id)
 {
     $count = 0;
     $model =& NModel::factory($this->name);
     $model->content_asset = $asset;
     $model->page_template_container_id = $container_id;
     if ($model->find()) {
         while ($model->fetch()) {
             $count++;
         }
     }
     unset($model);
     return $count;
 }
 function getWorkflow($page_content_id, $workflow_group_id, &$asset_controller, $completed = 0)
 {
     if (!$asset_controller || !($asset_model =& $asset_controller->getDefaultModel())) {
         return false;
     }
     $pk = $asset_model->primaryKey();
     $model =& NModel::factory($this->name);
     $model->page_content_id = $page_content_id;
     $model->workflow_group_id = $workflow_group_id;
     $model->asset = $asset_controller->name;
     $model->asset_id = $asset_model->{$pk};
     $model->completed = (int) $completed;
     if ($model->find(array('order_by' => 'id DESC'), true)) {
         return $model;
     }
     unset($model);
     return false;
 }
Example #30
0
 /**
  * auditTrail - Create an RSS feed of audit trail records.
  *		Shows $this->records many records.
  *
  * @return void
  **/
 function auditTrail()
 {
     if (defined('RSS_AUDIT_TRAIL') && RSS_AUDIT_TRAIL) {
         $this->auto_render = false;
         $count = 0;
         $token = $this->getToken();
         // It's got to be 32 characters - this keeps people from trying token=
         if ($length = strlen($token) < 32) {
             die;
         }
         if ($allowed = $this->checkToken($token)) {
             // Grab the last 50 results
             $audit_trail = NModel::factory('cms_audit_trail');
             $options['order_by'] = 'cms_created DESC';
             if ($audit_trail->find($options)) {
                 while ($audit_trail->fetch()) {
                     $audit_trail_controller = NController::factory('audit_trail');
                     $record = $audit_trail_controller->humanizeAuditTrailRecord($audit_trail);
                     //varDump($record);
                     $records[] = $record;
                     $count++;
                     if ($count >= $this->records) {
                         break;
                     }
                 }
             }
             $this->set('records', $records);
             $this->render(array('action' => 'audit_trail'));
         } else {
             print "Unauthorized access";
         }
     }
 }