当前位置: 首页>>代码示例>>PHP>>正文


PHP FLEXIUtilities::getCurrentVersions方法代码示例

本文整理汇总了PHP中FLEXIUtilities::getCurrentVersions方法的典型用法代码示例。如果您正苦于以下问题:PHP FLEXIUtilities::getCurrentVersions方法的具体用法?PHP FLEXIUtilities::getCurrentVersions怎么用?PHP FLEXIUtilities::getCurrentVersions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FLEXIUtilities的用法示例。


在下文中一共展示了FLEXIUtilities::getCurrentVersions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save


//.........这里部分代码省略.........
         $is_first_save = $isnew ? true : !isset($saved_fcitems[$model->get('id')]);
     }
     // Add item to saved items of the corresponding session array
     $saved_fcitems[$model->get('id')] = $timestamp = time();
     // Current time as seconds since Unix epoc;
     $session->set('saved_fcitems', $saved_fcitems, 'flexicontent');
     // ********************************************
     // Get categories added / removed from the item
     // ********************************************
     $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id');
     $db->setQuery($query);
     $after_cats = $db->loadObjectList('id');
     if (!$isnew) {
         $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats));
         foreach ($cats_added_ids as $cats_added_id) {
             $cats_added_titles[] = $after_cats[$cats_added_id]->title;
         }
         $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats));
         foreach ($cats_removed_ids as $cats_removed_id) {
             $cats_removed_titles[] = $before_cats[$cats_removed_id]->title;
         }
         $cats_altered = count($cats_added_ids) + count($cats_removed_ids);
         $after_maincat = $model->get('catid');
     }
     // *******************************************************************************************************************
     // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters
     // *******************************************************************************************************************
     $notify_emails = array();
     if ($is_first_save || $cats_altered || $params->get('nf_enable_debug', 0)) {
         // Get needed flags regarding the saved items
         $approve_version = 2;
         $pending_approval_state = -3;
         $draft_state = -4;
         $current_version = FLEXIUtilities::getCurrentVersions($item->id, true);
         // Get current item version
         $last_version = FLEXIUtilities::getLastVersions($item->id, true);
         // Get last version (=latest one saved, highest version id),
         // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them
         $needs_version_reviewal = !$isnew && $last_version > $current_version && !$canPublish && !$AutoApproveChanges;
         $needs_publication_approval = $isnew && $item->state == $pending_approval_state && !$canPublish;
         $draft_from_non_publisher = $item->state == $draft_state && !$canPublish;
         if ($draft_from_non_publisher) {
             // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button
             $nConf = false;
         } else {
             // Get notifications configuration and select appropriate emails for current saving case
             $nConf = $model->getNotificationsConf($params);
             //echo "<pre>"; print_r($nConf); "</pre>";
         }
         if ($nConf) {
             $states_notify_new = $params->get('states_notify_new', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5));
             if (empty($states_notify_new)) {
                 $states_notify_new = array();
             } else {
                 if (!is_array($states_notify_new)) {
                     $states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new);
                 }
             }
             $states_notify_existing = $params->get('states_notify_existing', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5));
             if (empty($states_notify_existing)) {
                 $states_notify_existing = array();
             } else {
                 if (!is_array($states_notify_existing)) {
                     $states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing);
                 }
             }
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:67,代码来源:items.php

示例2: addCurrentVersionData

 function addCurrentVersionData($item_id = null, $clean_database = false)
 {
     // check if the section was chosen to avoid adding data on static contents
     if (!FLEXI_CAT_EXTENSION) {
         return true;
     }
     $db =& $this->_db;
     $nullDate = $db->getNullDate();
     // @TODO: move somewhere else
     $this->formatFlexiPlugins();
     // Clean categories cache
     $catscache = JFactory::getCache('com_flexicontent_cats');
     $catscache->clean();
     // Get some basic info of all items, or of the given item
     $query = "SELECT c.id,c.catid,c.version,c.created,c.modified,c.created_by,c.introtext,c.`fulltext`" . " FROM #__content as c" . " JOIN #__categories as cat ON c.catid=cat.id " . " WHERE cat.extension='" . FLEXI_CAT_EXTENSION . "'" . ($item_id ? " AND c.id=" . $item_id : "");
     $db->setQuery($query);
     $rows = $db->loadObjectList('id');
     if (!$item_id) {
         // Get current version ids of ALL ITEMS not having current versions
         $diff_arrays = $this->getDiffVersions();
     } else {
         // Get current version id of a SPECIFIC ITEM
         $diff_arrays = array(FLEXIUtilities::getCurrentVersions($item_id));
     }
     //$jcorefields = flexicontent_html::getJCoreFields();
     $add_cats = true;
     $add_tags = true;
     // For all items not having the current version, add it
     foreach ($diff_arrays as $item) {
         $item_id = @(int) $item["id"];
         if (isset($rows[$item_id])) {
             $row =& $rows[$item_id];
             // Get field values of the current item version
             $query = "SELECT f.id,fir.value,f.field_type,f.name,fir.valueorder,f.iscore " . " FROM #__flexicontent_fields_item_relations as fir" . " LEFT JOIN #__flexicontent_fields as f on f.id=fir.field_id " . " WHERE fir.item_id=" . $row->id . " AND f.iscore=0";
             // old versions stored categories & tags into __flexicontent_fields_item_relations
             $db->setQuery($query);
             $fieldsvals = $db->loadObjectList();
             // Delete existing unversioned (current version) field values ONLY if we are asked to 'clean' the database
             if ($clean_database && $fieldsvals) {
                 $query = 'DELETE FROM #__flexicontent_fields_item_relations WHERE item_id = ' . $row->id;
                 $db->setQuery($query);
                 $db->query();
             }
             // Delete any existing versioned field values to avoid conflicts, this maybe redudant, since they should not exist,
             // but we do it anyway because someone may have truncated or delete records only in table 'flexicontent_versions' ...
             // NOTE: we do not delete data with field_id negative as these exist only in the versioning table
             $query = 'DELETE FROM #__flexicontent_items_versions WHERE item_id = ' . $row->id . ' AND version= ' . $row->version . ' AND field_id > 0';
             $db->setQuery($query);
             $db->query();
             // Add the 'maintext' field to the fields array for adding to versioning table
             $f = new stdClass();
             $f->id = 1;
             $f->iscore = 1;
             $f->valueorder = 1;
             $f->field_type = "maintext";
             $f->name = "text";
             $f->value = $row->introtext;
             if (JString::strlen($row->fulltext) > 1) {
                 $f->value .= '<hr id="system-readmore" />' . $row->fulltext;
             }
             if (substr($f->value, 0, 3) != "<p>") {
                 $f->value = "<p>" . $f->value . "</p>";
             }
             $fieldsvals[] = $f;
             // Add the 'categories' field to the fields array for adding to versioning table
             $query = "SELECT catid FROM #__flexicontent_cats_item_relations WHERE itemid='" . $row->id . "';";
             $db->setQuery($query);
             $categories = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
             if (!$categories || !count($categories)) {
                 $categories = array($catid = $row->catid);
                 $query = "INSERT INTO #__flexicontent_cats_item_relations VALUES('{$catid}','" . $row->id . "', '0');";
                 $db->setQuery($query);
                 $db->query();
             }
             $f = new stdClass();
             $f->id = 13;
             $f->iscore = 1;
             $f->valueorder = 1;
             $f->version = (int) $row->version;
             $f->value = serialize($categories);
             if ($add_cats) {
                 $fieldsvals[] = $f;
             }
             // Add the 'tags' field to the fields array for adding to versioning table
             $query = "SELECT tid FROM #__flexicontent_tags_item_relations WHERE itemid='" . $row->id . "';";
             $db->setQuery($query);
             $tags = FLEXI_J16GE ? $db->loadColumn() : $db->loadResultArray();
             $f = new stdClass();
             $f->id = 14;
             $f->iscore = 1;
             $f->valueorder = 1;
             $f->version = (int) $row->version;
             $f->value = serialize($tags);
             if ($add_tags) {
                 $fieldsvals[] = $f;
             }
             // Add field values to field value versioning table
             foreach ($fieldsvals as $fieldval) {
                 // add the new values to the database
                 $obj = new stdClass();
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:flexicontent.php

示例3: deletePreparaty

	/**
	 * @param int       $id
	 * @param UserTable $user
	 */
	private function deletePreparaty( $id, $user )
	{
		global $_CB_framework;
                $db = JFactory::getDBO();
                require_once ( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_flexicontent/classes/flexicontent.helper.php' );
                //require_once (JPATH_COMPONENT_SITE.DS.'classes'.DS.'flexicontent.helper.php');
                $state = -2;
		$app  = JFactory::getApplication();
		$user = JFactory::getUser();
		$dispatcher = JDispatcher::getInstance();
		JRequest::setVar("isflexicontent", "yes");
		static $event_failed_notice_added = false;
		
                $query = 'SELECT id FROM #__content'
				. ' WHERE id = '.(int)$id.
                        " AND created_by = " . (int) $user->get( 'id' );
                $db->setQuery( $query );
			
                if(!$db->loadResult()){
                    $profileUrl				=	$_CB_framework->userProfileUrl( $user->get( 'id' ) , false, '' );

                    cbRedirect( $profileUrl, CBTxt::T( 'You can\'t deleted this drug!' ) );
                }
                
		if ( $id )
		{
			$v = FLEXIUtilities::getCurrentVersions((int)$id);
			
			$query = 'UPDATE #__content'
				. ' SET state = ' . (int)$state
				. ' WHERE id = '.(int)$id
				//. ' AND ( checked_out = 0 OR ( checked_out = ' . (int) $user->get('id'). ' ) )'
			;
			$db->setQuery( $query );
			$db->query();
			if ( $db->getErrorNum() )  if (FLEXI_J16GE) throw new Exception($db->getErrorMsg(), 500); else JError::raiseError(500, $db->getErrorMsg());
			
			$query = 'UPDATE #__flexicontent_items_tmp'
				. ' SET state = ' . (int)$state
				. ' WHERE id = '.(int)$id
				//. ' AND ( checked_out = 0 OR ( checked_out = ' . (int) $user->get('id'). ' ) )'
			;
			$db->setQuery( $query );
			$db->query();
			if ( $db->getErrorNum() )  if (FLEXI_J16GE) throw new Exception($db->getErrorMsg(), 500); else JError::raiseError(500, $db->getErrorMsg());
			
			$query = 'UPDATE #__flexicontent_items_versions'
				. ' SET value = ' . (int)$state
				. ' WHERE item_id = '.(int)$id
				. ' AND valueorder = 1'
				. ' AND field_id = 10'
				. ' AND version = ' .(int)$v['version']
				;
			$db->setQuery( $query );
			$db->query();
			if ( $db->getErrorNum() )  if (FLEXI_J16GE) throw new Exception($db->getErrorMsg(), 500); else JError::raiseError(500, $db->getErrorMsg());
		}
		
		
		// ****************************************************************
		// Trigger Event 'onContentChangeState' of Joomla's Content plugins
		// ****************************************************************
		if (FLEXI_J16GE) {
			// Make sure we import flexicontent AND content plugins since we will be triggering their events
			JPluginHelper::importPlugin('content');
			
			// PREPARE FOR TRIGGERING content events
			// We need to fake joomla's states ... when triggering events
			$fc_state = $state;
			if ( in_array($fc_state, array(1,-5)) ) $jm_state = 1;           // published states
			else if ( in_array($fc_state, array(0,-3,-4)) ) $jm_state = 0;   // unpublished states
			else $jm_state = $fc_state;                                      // trashed & archive states
			$fc_itemview = $app->isSite() ? FLEXI_ITEMVIEW : 'item';
			
			$item = new stdClass();
			
			// Compatibility steps (including Joomla compatible state),
			// so that 3rd party plugins using the change state event work properly
		  JRequest::setVar('view', 'article');	  JRequest::setVar('option', 'com_content');
			$item->state = $jm_state;
			
			$result = $dispatcher->trigger($this->event_change_state, array('com_content.article', (array) $id, $jm_state));
			
			// Revert compatibilty steps ... the $item->state is not used further regardless if it was changed,
			// besides the event_change_state using plugin should have updated DB state value anyway
			JRequest::setVar('view', $fc_itemview);	  JRequest::setVar('option', 'com_flexicontent');
			if ($item->state == $jm_state) $item->state = $fc_state;  // this check is redundant, item->state is not used further ...
			
			if (in_array(false, $result, true) && !$event_failed_notice_added) {
				JError::raiseNotice(10, JText::_('One of plugin event handler for onContentChangeState failed') );
				$event_failed_notice_added = true;
				return false;
			}
		}
		$profileUrl				=	$_CB_framework->userProfileUrl( $user->get( 'id' ) , false, '' );

//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:component.cbpreparaty.php

示例4: _check_viewing_access


//.........这里部分代码省略.........
             }
         } else {
             if ($item_is_scheduled && !$inactive_notice_set) {
                 // Item edittable, set warning that ...
                 JError::raiseNotice(404, JText::_('FLEXI_CONTENT_UNAVAILABLE_ITEM_SCHEDULED'));
                 $inactive_notice_set = true;
             }
         }
         // (d) Check that current item category or all items categories are published
         if (!$cats_are_published && !$ignore_publication) {
             // Terminate execution with a HTTP not-found Server Error
             $msg = $cats_np_err_mssg . $title_str;
             if (FLEXI_J16GE) {
                 throw new Exception($msg, 404);
             } else {
                 JError::raiseError(404, $msg);
             }
         } else {
             if (!$cats_are_published && !$inactive_notice_set) {
                 // Item edittable, set warning that item's (ancestor) category is unpublished
                 JError::raiseNotice(404, $cats_np_err_mssg);
                 $inactive_notice_set = true;
             }
         }
         //*******************************************************************************************
         // STEP D: CHECK viewing access in relation to if user being logged and being owner / editor
         // (a) redirect user previewing a non-current item version, to either current item version or to refer if has no edit permission
         // (b) redirect item owner to previous page if user has no access (read/edit) to the item
         // (c) redirect unlogged user to login, so that user can possible login to privileged account
         // (d) redirect unauthorized logged user to the unauthorized page (if this is set)
         // (e) finally raise a 403 forbidden Server Error if user is unauthorized to access item
         //*******************************************************************************************
         // SPECIAL case when previewing an non-current version of an item, this is allowed only if user can edit the item
         $current_version = FLEXIUtilities::getCurrentVersions($this->_id, true);
         // Get current item version
         if ($version && $version != $current_version && !$canedititem && !$previewing_and_unlogged) {
             // (a) redirect user previewing a non-current item version, to either current item version or to refer if has no edit permission
             JError::raiseNotice(403, JText::_('FLEXI_ALERTNOTAUTH_PREVIEW_UNEDITABLE') . "<br />" . JText::_('FLEXI_ALERTNOTAUTH_TASK'));
             if ($item_n_cat_active && $canviewitem) {
                 $app->redirect(JRoute::_(FlexicontentHelperRoute::getItemRoute($this->_item->slug, $this->_item->categoryslug, 0, $this->_item)));
             } else {
                 $app->redirect($referer);
                 // Item not viewable OR no view access, redirect to refer page
             }
         } else {
             if (!$item_n_cat_active && !$previewing_and_unlogged) {
                 if (!$caneditstate && ($item_state_pending || $item_state_draft) && $isOwner) {
                     // no redirect, SET message to owners, to wait for approval or to request approval of their content
                     $app->enqueueMessage(JText::_($item_state_pending ? 'FLEXI_ALERT_VIEW_OWN_PENDING_STATE' : 'FLEXI_ALERT_VIEW_OWN_DRAFT_STATE'), 'notice');
                 } else {
                     if (!$canedititem && !$caneditstate && $isOwner) {
                         // (b) redirect item owner to previous page if user cannot access (read/edit) the item
                         JError::raiseNotice(403, JText::_($item_state_pending ? 'FLEXI_ALERTNOTAUTH_VIEW_OWN_PENDING' : 'FLEXI_ALERTNOTAUTH_VIEW_OWN_UNPUBLISHED'));
                         $app->redirect($referer);
                     } else {
                         if ($canedititem || $caneditstate) {
                             // no redirect, SET notice to the editors, that they are viewing unreadable content because they can edit the item
                             $app->enqueueMessage(JText::_('FLEXI_CONTENT_ACCESS_ALLOWED_BECAUSE_EDITABLE_PUBLISHABLE'), 'notice');
                         } else {
                             $app->enqueueMessage('INTERNAL ERROR: item inactive but checks were ignored despite current user not begin item owner or item assigned editor', 'notice');
                             $app->redirect($referer);
                         }
                     }
                 }
             } else {
                 if (!$canviewitem && !$canedititem || !$item_n_cat_active) {
开发者ID:nettdotkomm,项目名称:flexicontent-cck,代码行数:67,代码来源:item.php

示例5: setitemstate

 /**
  * Method to change the state of an item
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.0
  */
 function setitemstate($id, $state = 1)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     JRequest::setVar("isflexicontent", "yes");
     static $event_failed_notice_added = false;
     if ($id) {
         $v = FLEXIUtilities::getCurrentVersions((int) $id);
         $query = 'UPDATE #__content' . ' SET state = ' . (int) $state . ' WHERE id = ' . (int) $id;
         $this->_db->setQuery($query);
         $this->_db->query();
         if ($this->_db->getErrorNum()) {
             if (FLEXI_J16GE) {
                 throw new Exception($this->_db->getErrorMsg(), 500);
             } else {
                 JError::raiseError(500, $this->_db->getErrorMsg());
             }
         }
         $query = 'UPDATE #__flexicontent_items_tmp' . ' SET state = ' . (int) $state . ' WHERE id = ' . (int) $id;
         $this->_db->setQuery($query);
         $this->_db->query();
         if ($this->_db->getErrorNum()) {
             if (FLEXI_J16GE) {
                 throw new Exception($this->_db->getErrorMsg(), 500);
             } else {
                 JError::raiseError(500, $this->_db->getErrorMsg());
             }
         }
         $query = 'UPDATE #__flexicontent_items_versions' . ' SET value = ' . (int) $state . ' WHERE item_id = ' . (int) $id . ' AND valueorder = 1' . ' AND field_id = 10' . ' AND version = ' . (int) $v['version'];
         $this->_db->setQuery($query);
         $this->_db->query();
         if ($this->_db->getErrorNum()) {
             if (FLEXI_J16GE) {
                 throw new Exception($this->_db->getErrorMsg(), 500);
             } else {
                 JError::raiseError(500, $this->_db->getErrorMsg());
             }
         }
     }
     // ****************************************************************
     // Trigger Event 'onContentChangeState' of Joomla's Content plugins
     // ****************************************************************
     if (FLEXI_J16GE) {
         // Make sure we import flexicontent AND content plugins since we will be triggering their events
         JPluginHelper::importPlugin('content');
         // PREPARE FOR TRIGGERING content events
         // We need to fake joomla's states ... when triggering events
         $fc_state = $state;
         if (in_array($fc_state, array(1, -5))) {
             $jm_state = 1;
         } else {
             if (in_array($fc_state, array(0, -3, -4))) {
                 $jm_state = 0;
             } else {
                 $jm_state = $fc_state;
             }
         }
         // trashed & archive states
         $fc_itemview = $app->isSite() ? FLEXI_ITEMVIEW : 'item';
         $item = new stdClass();
         // Compatibility steps (including Joomla compatible state),
         // so that 3rd party plugins using the change state event work properly
         JRequest::setVar('view', 'article');
         JRequest::setVar('option', 'com_content');
         $item->state = $jm_state;
         $result = $dispatcher->trigger($this->event_change_state, array('com_content.article', (array) $id, $jm_state));
         // Revert compatibilty steps ... the $item->state is not used further regardless if it was changed,
         // besides the event_change_state using plugin should have updated DB state value anyway
         JRequest::setVar('view', $fc_itemview);
         JRequest::setVar('option', 'com_flexicontent');
         if ($item->state == $jm_state) {
             $item->state = $fc_state;
         }
         // this check is redundant, item->state is not used further ...
         if (in_array(false, $result, true) && !$event_failed_notice_added) {
             JError::raiseNotice(10, JText::_('One of plugin event handler for onContentChangeState failed'));
             $event_failed_notice_added = true;
             return false;
         }
     }
     return true;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:90,代码来源:parentclassitem.php

示例6: save


//.........这里部分代码省略.........
		// Get categories added / removed from the item
		// ********************************************
		$query 	= 'SELECT DISTINCT c.id, c.title FROM #__categories AS c'
			. ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id'
			. ' WHERE rel.itemid = '.(int) $model->get('id');
		$db->setQuery( $query );
		$after_cats = $db->loadObjectList('id');
		if ( !$isnew ) {
			$cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats));
			foreach($cats_added_ids as $cats_added_id) {
				$cats_added_titles[] = $after_cats[$cats_added_id]->title;
			}
			
			$cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats));
			foreach($cats_removed_ids as $cats_removed_id) {
				$cats_removed_titles[] = $before_cats[$cats_removed_id]->title;
			}
			$cats_altered = count($cats_added_ids) + count($cats_removed_ids);
			$after_maincat = $model->get('catid');
		}
		
		
		// *******************************************************************************************************************
		// We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters
		// *******************************************************************************************************************
		$notify_emails = array();
		if ( $is_first_save || $cats_altered || $params->get('nf_enable_debug',0) )
		{
			// Get needed flags regarding the saved items
			$approve_version = 2;
			$pending_approval_state = -3;
			$draft_state = -4;
			
			$current_version = FLEXIUtilities::getCurrentVersions($item->id, true); // Get current item version
			$last_version    = FLEXIUtilities::getLastVersions($item->id, true);    // Get last version (=latest one saved, highest version id),
			
			// $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them
			$needs_version_reviewal     = !$isnew && ($last_version > $current_version) && !$canPublish;
			$needs_publication_approval =  $isnew && ($item->state == $pending_approval_state) && !$canPublish;
			
			$draft_from_non_publisher = $item->state==$draft_state && !$canPublish;
			
			if ($draft_from_non_publisher) {
				// Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button
				$nConf = false;
			} else {
				// Get notifications configuration and select appropriate emails for current saving case
				$nConf = $model->getNotificationsConf($params);  //echo "<pre>"; print_r($nConf); "</pre>";
			}
			
			if ($nConf)
			{
				$states_notify_new = $params->get('states_notify_new', array(1,0,(FLEXI_J16GE ? 2:-1),-3,-4,-5));
				if ( empty($states_notify_new) )						$states_notify_new = array();
				else if ( ! is_array($states_notify_new) )	$states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new);
				
				$states_notify_existing = $params->get('states_notify_existing', array(1,0,(FLEXI_J16GE ? 2:-1),-3,-4,-5));
				if ( empty($states_notify_existing) )						$states_notify_existing = array();
				else if ( ! is_array($states_notify_existing) )	$states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing);

				$n_state_ok = in_array($item->state, $states_notify_new);
				$e_state_ok = in_array($item->state, $states_notify_existing);
				
				if ($needs_publication_approval)   $notify_emails = $nConf->emails->notify_new_pending;
				else if ($isnew && $n_state_ok)    $notify_emails = $nConf->emails->notify_new;
				else if ($isnew)                   $notify_emails = array();
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:67,代码来源:_controller.php

示例7: save_import


//.........这里部分代码省略.........
                                // Get categories added / removed from the item
                                // ********************************************
                                $query 	= 'SELECT DISTINCT c.id, c.title FROM #__categories AS c'
                                        . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id'
                                        . ' WHERE rel.itemid = '.(int) $model->get('id');
                                $db->setQuery( $query );
                                $after_cats = $db->loadObjectList('id');
                                if ( !$isnew ) {
                                        $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats));
                                        foreach($cats_added_ids as $cats_added_id) {
                                                $cats_added_titles[] = $after_cats[$cats_added_id]->title;
                                        }

                                        $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats));
                                        foreach($cats_removed_ids as $cats_removed_id) {
                                                $cats_removed_titles[] = $before_cats[$cats_removed_id]->title;
                                        }
                                        $cats_altered = count($cats_added_ids) + count($cats_removed_ids);
                                        $after_maincat = $model->get('catid');
                                }


                                // *******************************************************************************************************************
                                // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters
                                // *******************************************************************************************************************
                                $notify_emails = array();
                                if ( $is_first_save || $cats_altered || $params->get('nf_enable_debug',0) )
                                {
                                        // Get needed flags regarding the saved items
                                        $approve_version = 2;
                                        $pending_approval_state = -3;
                                        $draft_state = -4;

                                        $current_version = FLEXIUtilities::getCurrentVersions($item->id, true); // Get current item version
                                        $last_version    = FLEXIUtilities::getLastVersions($item->id, true);    // Get last version (=latest one saved, highest version id),

                                        // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them
                                        $needs_version_reviewal     = !$isnew && ($last_version > $current_version) && !$canPublish;
                                        $needs_publication_approval =  $isnew && ($item->state == $pending_approval_state) && !$canPublish;

                                        $draft_from_non_publisher = $item->state==$draft_state && !$canPublish;

                                        if ($draft_from_non_publisher) {
                                                // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button
                                                $nConf = false;
                                        } else {
                                                // Get notifications configuration and select appropriate emails for current saving case
                                                $nConf = $model->getNotificationsConf($params);  //echo "<pre>"; print_r($nConf); "</pre>";
                                        }

                                        if ($nConf)
                                        {
                                                $states_notify_new = $params->get('states_notify_new', array(1,0,(FLEXI_J16GE ? 2:-1),-3,-4,-5));
                                                if ( empty($states_notify_new) )						$states_notify_new = array();
                                                else if ( ! is_array($states_notify_new) )	$states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new);

                                                $states_notify_existing = $params->get('states_notify_existing', array(1,0,(FLEXI_J16GE ? 2:-1),-3,-4,-5));
                                                if ( empty($states_notify_existing) )						$states_notify_existing = array();
                                                else if ( ! is_array($states_notify_existing) )	$states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing);

                                                $n_state_ok = in_array($item->state, $states_notify_new);
                                                $e_state_ok = in_array($item->state, $states_notify_existing);

                                                if ($needs_publication_approval)   $notify_emails = $nConf->emails->notify_new_pending;
                                                else if ($isnew && $n_state_ok)    $notify_emails = $nConf->emails->notify_new;
                                                else if ($isnew)                   $notify_emails = array();
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:67,代码来源:controller.php


注:本文中的FLEXIUtilities::getCurrentVersions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。