コード例 #1
0
	public function dashboard($find_state = 'review', $page = 'index'){
		$EE =& get_instance();
		$EE->lang->loadfile('nsm_pp_workflow');
		$EE->load->helper('date');
		
		if(!$this->settings){
			// get extension settings
			if(!class_exists('Nsm_pp_workflow_ext')){
				include(dirname(__FILE__).'/ext.nsm_pp_workflow.php');
			}
			$nsm_pp_ext = new Nsm_pp_workflow_ext();
			$this->settings = $nsm_pp_ext->settings;
		}

		$channel_ids = $this->_returnChannelIDs($this->settings);

		$vars = array(
		    'EE' => $EE, 
		    'entries' => false, 
		    'error_tag' => $find_state.'_no_results', 
		    'filter_state' => $find_state,
		    'extension_settings_url' => BASE.AMP.'C=addons_extensions'.AMP.'M=extension_settings'.AMP.'file=nsm_pp_workflow'
		);
		
		if(!class_exists('Nsm_pp_workflow_model')){
			include(dirname(__FILE__).'/models/nsm_pp_workflow_model.php');
		}
		
		$workflow_objects = false;

		if($channel_ids){
			$workflow_objects = Nsm_pp_workflow_model::findByState($find_state, $channel_ids);
		}else{
			$vars['error_tag'] = 'no_channels';
		}

		if($workflow_objects){
			$vars['entries'] = array();
			$entry_ids = Nsm_pp_workflow_model::getCollectionEntryIds($workflow_objects);
			$channel_entries = $this->_returnEntries($entry_ids);
			foreach($channel_entries as $entry_row){
				$entry = $entry_row;
				$entry['edit_date'] = strtotime($entry['edit_date']);
				$entry['days_in_review'] = ceil(($entry['last_review_date'] - mktime()) / (24 * 60 * 60));
				if($entry['days_in_review'] < 1){ $entry['days_in_review'] = "None"; }
				$entry['days_since_edit'] = ceil(($entry['last_review_date'] - $entry['edit_date']) / (24 * 60 * 60));
				if($entry['days_since_edit'] < 1){ $entry['days_since_edit'] = "None"; }
				$entry['cp_entry_url'] = BASE.AMP.'C=content_publish'.AMP.'M=entry_form'.AMP.'channel_id='.$entry['channel_id'].AMP.'entry_id='.$entry['entry_id'];
				$vars['entries'][] = $entry;
			}
		}
		$out = $this->EE->load->view("module/index", $vars, TRUE);
		return $this->_renderLayout($page, $out);
	}
コード例 #2
0
	/**
	 * Called near the end of the entry delete function, this allows you to sync your records if any are tied to channel entry_ids. Returns nothing.
	 *
	 * @param array $entry_ids The deleted entries
	 * @return void
	 */
	public function publish_data_delete_db($entry_ids) {
		if(!class_exists('Nsm_pp_workflow_model')){
			include(dirname(__FILE__).'/models/nsm_pp_workflow_model.php');
		}
		foreach($entry_ids['entry_ids'] as $entry_id){
			$nsm_pp_model = Nsm_pp_workflow_model::findByEntryId($entry_id);
			if($nsm_pp_model !== false){
				$nsm_pp_model->delete();
			}
		}
	}