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


PHP FLEXIUtilities::getLastVersions方法代码示例

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


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

示例1: save


//.........这里部分代码省略.........
     // 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);
                 }
             }
             $n_state_ok = in_array($item->state, $states_notify_new);
             $e_state_ok = in_array($item->state, $states_notify_existing);
开发者ID:khetsothea,项目名称:flexicontent-cck,代码行数:67,代码来源:items.php

示例2: getDiffVersions

 function getDiffVersions($current_versions = array(), $last_versions = array())
 {
     // check if the category was chosen to avoid adding data on static contents
     if (!FLEXI_CAT_EXTENSION) {
         return array();
     }
     if (!$current_versions) {
         $current_versions = FLEXIUtilities::getCurrentVersions();
     }
     if (!$last_versions) {
         $last_versions = FLEXIUtilities::getLastVersions();
     }
     $difference = $current_versions;
     foreach ($current_versions as $key1 => $value1) {
         foreach ($last_versions as $key2 => $value2) {
             if ($value1["id"] == $value2["id"] && $value1["version"] == $value2["version"]) {
                 unset($difference[$key1]);
             }
         }
     }
     return $difference;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:22,代码来源:flexicontent.php

示例3: cleanupOldTables

 /**
  * Method to delete old core fields data in the fields_items_relations table
  * Delete also old versions fields data
  * Alter value fields to mediumtext in order to store large items
  * 
  * @access	public
  * @return	boolean	True on success
  * @since 1.5
  */
 function cleanupOldTables()
 {
     // Check for request forgeries
     JRequest::checkToken('request') or jexit('Invalid Token');
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     $queries = array();
     // alter some table field types
     $queries[] = "ALTER TABLE #__flexicontent_fields_item_relations CHANGE `value` `value` MEDIUMTEXT";
     $queries[] = "ALTER TABLE #__flexicontent_items_versions CHANGE `value` `value` MEDIUMTEXT";
     $queries[] = "ALTER TABLE #__flexicontent_items_ext" . "  CHANGE `search_index` `search_index` MEDIUMTEXT" . ", CHANGE `sub_items` `sub_items` TEXT" . ", CHANGE `sub_categories` `sub_categories` TEXT" . ", CHANGE `related_items` `related_items` TEXT";
     foreach ($queries as $query) {
         $db->setQuery($query);
         $db->query();
     }
     $query = "SELECT id,version,created,created_by FROM #__content " . (!FLEXI_J16GE ? "WHERE sectionid='" . FLEXI_SECTION . "'" : "");
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     //$jcorefields = flexicontent_html::getJCoreFields();
     $add_cats = true;
     $add_tags = true;
     $clean_database = true;
     // For all items not having the current version, add it
     $last_versions = FLEXIUtilities::getLastVersions();
     foreach ($rows as $row) {
         $lastversion = @$last_versions[$row->id]['version'];
         if ($row->version > $lastversion) {
             // Get field values of the current item version
             $query = "SELECT f.id,fir.value,f.field_type,f.name,fir.valueorder,fir.suborder,f.iscore " . " FROM #__flexicontent_fields_item_relations as fir" . " 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);
             $fields = $db->loadObjectList();
             // Delete old data
             if ($clean_database && $fields) {
                 $query = 'DELETE FROM #__flexicontent_fields_item_relations WHERE item_id = ' . $row->id;
                 $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->suborder = 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>";
             }
             $fields[] = $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->suborder = 1;
             $f->version = (int) $row->version;
             $f->value = serialize($categories);
             if ($add_cats) {
                 $fields[] = $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->suborder = 1;
             $f->version = (int) $row->version;
             $f->value = serialize($tags);
             if ($add_tags) {
                 $fields[] = $f;
             }
             // Add field values to field value versioning table
             foreach ($fields as $field) {
                 // add the new values to the database
//.........这里部分代码省略.........
开发者ID:noxidsoft,项目名称:flexicontent-cck,代码行数:101,代码来源:controller.php

示例4: saveFields

 /**
  * Method to save field values of the item in field versioning DB table or in ..._fields_item_relations DB table 
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.0
  */
 function saveFields($isnew, &$item, &$data, &$files)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     $cparams = $this->_cparams;
     $use_versioning = $cparams->get('use_versioning', 1);
     $print_logging_info = $cparams->get('print_logging_info');
     $last_version = FLEXIUtilities::getLastVersions($item->id, true);
     $mval_query = true;
     if ($print_logging_info) {
         global $fc_run_times;
     }
     if ($print_logging_info) {
         $start_microtime = microtime(true);
     }
     //*********************************
     // Checks for untranslatable fields
     //*********************************
     // CASE 1. Check if saving an item that translates an original content in site's default language
     // ... Decide whether to retrieve field values of untranslatable fields from the original content item
     $enable_translation_groups = $cparams->get('enable_translation_groups');
     $is_content_default_lang = substr(flexicontent_html::getSiteDefaultLang(), 0, 2) == substr($item->language, 0, 2);
     $get_untraslatable_values = $enable_translation_groups && !$is_content_default_lang && $item->lang_parent_id && $item->lang_parent_id != $item->id;
     // CASE 2. Check if saving an original content item (item's language is site default language)
     // ... Get item ids of translating items
     if ($is_content_default_lang && $this->_id) {
         $query = 'SELECT ie.item_id' . ' FROM #__flexicontent_items_ext as ie' . ' WHERE ie.lang_parent_id = ' . (int) $this->_id . '  AND ie.item_id <> ' . (int) $this->_id;
         // DO NOT include the item itself in associated translations !!
         $this->_db->setQuery($query);
         $assoc_item_ids = FLEXI_J16GE ? $this->_db->loadColumn() : $this->_db->loadResultArray();
     }
     if (empty($assoc_item_ids)) {
         $assoc_item_ids = array();
     }
     // ***************************************************************************************************************************
     // Get item's fields ... and their values (for untranslatable fields the field values from original content item are retrieved
     // ***************************************************************************************************************************
     $fields = $this->getExtrafields($force = true, $get_untraslatable_values ? $item->lang_parent_id : 0);
     // ******************************************************************************************************************
     // Loop through Fields triggering onBeforeSaveField Event handlers, this was seperated from the rest of the process
     // to give chance to ALL fields to check their DATA and cancel item saving process before saving any new field values
     // ******************************************************************************************************************
     $searchindex = array();
     //$qindex = array();
     if ($fields) {
         foreach ($fields as $field) {
             // Set vstate property into the field object to allow this to be changed be the before saving  field event handler
             $field->item_vstate = $data['vstate'];
             if (FLEXI_J16GE) {
                 $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
             } else {
                 if (FLEXI_ACCESS && $user->gid < 25) {
                     $is_editable = !$field->valueseditable || FAccess::checkAllContentAccess('com_content', 'submit', 'users', $user->gmid, 'field', $field->id);
                 } else {
                     $is_editable = 1;
                 }
             }
             // FORM HIDDEN FIELDS (FRONTEND/BACKEND) AND (ACL) UNEDITABLE FIELDS: maintain their DB value ...
             if ($app->isSite() && ($field->formhidden == 1 || $field->formhidden == 3 || $field->parameters->get('frontend_hidden')) || $app->isAdmin() && ($field->formhidden == 2 || $field->formhidden == 3 || $field->parameters->get('backend_hidden')) || !$is_editable) {
                 $postdata[$field->name] = $field->value;
                 // UNTRANSLATABLE (CUSTOM) FIELDS: maintain their DB value ...
             } else {
                 if ($get_untraslatable_values && $field->untranslatable) {
                     $postdata[$field->name] = $field->value;
                     // CORE FIELDS: if not set maintain their DB value ...
                 } else {
                     if ($field->iscore) {
                         $postdata[$field->name] = @$data[$field->name];
                         if (is_array($postdata[$field->name]) && !count($postdata[$field->name]) || !is_array($postdata[$field->name]) && !strlen(trim($postdata[$field->name]))) {
                             $postdata[$field->name] = $field->value;
                         }
                         // OTHER CUSTOM FIELDS (not hidden and not untranslatable)
                     } else {
                         $postdata[$field->name] = !FLEXI_J16GE ? @$data[$field->name] : @$data['custom'][$field->name];
                     }
                 }
             }
             // Unserialize values already serialized values, e.g. (a) if current values used are from DB or (b) are being imported from CSV file
             if (!is_array($postdata[$field->name])) {
                 $postdata[$field->name] = strlen($postdata[$field->name]) ? array($postdata[$field->name]) : array();
             }
             //echo "<b>{$field->field_type}</b>: <br/> <pre>".print_r($postdata[$field->name], true)."</pre>\n";
             foreach ($postdata[$field->name] as $i => $postdata_val) {
                 if (@unserialize($postdata_val) !== false || $postdata_val === 'b:0;') {
                     $postdata[$field->name][$i] = unserialize($postdata_val);
                 }
             }
             // Trigger plugin Event 'onBeforeSaveField'
             $fieldname = $field->iscore ? 'core' : $field->field_type;
             $result = FLEXIUtilities::call_FC_Field_Func($fieldname, 'onBeforeSaveField', array(&$field, &$postdata[$field->name], &$files[$field->name], &$item));
             //$qindex[$field->name] = NULL;
             //$result = FLEXIUtilities::call_FC_Field_Func($fieldname, 'onBeforeSaveField', array( &$field, &$postdata[$field->name], &$files[$field->name], &$item, &$qindex[$field->name] ));
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:parentclassitem.php

示例5: saveFields

    /**
     * Method to save field values of the item in field versioning DB table or in ..._fields_item_relations DB table 
     *
     * @access	public
     * @return	boolean	True on success
     * @since	1.0
     */
    function saveFields($isnew, &$item, &$data, &$files, &$old_item = null, &$core_data_via_events = null)
    {
        if (!$old_item) {
            $old_item =& $item;
        }
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        $dispatcher = JDispatcher::getInstance();
        $cparams = $this->_cparams;
        $use_versioning = $cparams->get('use_versioning', 1);
        $print_logging_info = $cparams->get('print_logging_info');
        $last_version = (int) FLEXIUtilities::getLastVersions($item->id, true);
        $mval_query = true;
        if ($print_logging_info) {
            global $fc_run_times;
        }
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        // ********************************
        // Checks for untranslatable fields
        // ********************************
        // CASE 1. Check if saving an item that translates an original content in site's default language
        // ... Decide whether to retrieve field values of untranslatable fields from the original content item
        $enable_translation_groups = flexicontent_db::useAssociations();
        //$cparams->get('enable_translation_groups');
        $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2);
        $is_content_default_lang = $site_default == substr($item->language, 0, 2);
        $get_untraslatable_values = $enable_translation_groups && !$is_content_default_lang;
        if ($enable_translation_groups) {
            $langAssocs = $this->getLangAssocs();
            //}
            //if ($enable_translation_groups /*&& $is_content_default_lang*/)
            //{
            // ... Get item ids of the associated items, so that we save into the untranslatable fields
            $_langAssocs = $langAssocs;
            unset($_langAssocs[$this->_id]);
            $assoc_item_ids = array_keys($_langAssocs);
        }
        if (empty($assoc_item_ids)) {
            $assoc_item_ids = array();
        }
        // ***************************************************************************************************************************
        // Get item's fields ... and their values (for untranslatable fields the field values from original content item are retrieved
        // ***************************************************************************************************************************
        $original_content_id = 0;
        if ($get_untraslatable_values) {
            foreach ($langAssocs as $content_id => $_assoc) {
                if ($site_default == substr($_assoc->language, 0, 2)) {
                    $original_content_id = $content_id;
                    break;
                }
            }
        }
        //JFactory::getApplication()->enqueueMessage(__FUNCTION__.'(): '.$original_content_id.' '.print_r($assoc_item_ids, true),'message');
        $fields = $this->getExtrafields($force = true, $original_content_id, $old_item);
        // ******************************************************************************************************************
        // Loop through Fields triggering onBeforeSaveField Event handlers, this was seperated from the rest of the process
        // to give chance to ALL fields to check their DATA and cancel item saving process before saving any new field values
        // ******************************************************************************************************************
        $searchindex = array();
        //$qindex = array();
        $core_data_via_events = array();
        // Extra validation for some core fields via onBeforeSaveField
        if ($fields) {
            $core_via_post = array('title' => 1, 'text' => 1);
            foreach ($fields as $field) {
                // Set vstate property into the field object to allow this to be changed be the before saving  field event handler
                $field->item_vstate = $data['vstate'];
                $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id);
                $maintain_dbval = false;
                // FORM HIDDEN FIELDS (FRONTEND/BACKEND) AND (ACL) UNEDITABLE FIELDS: maintain their DB value ...
                if ($app->isSite() && ($field->formhidden == 1 || $field->formhidden == 3 || $field->parameters->get('frontend_hidden')) || $app->isAdmin() && ($field->formhidden == 2 || $field->formhidden == 3 || $field->parameters->get('backend_hidden')) || !$is_editable) {
                    $postdata[$field->name] = $field->value;
                    $maintain_dbval = true;
                    // UNTRANSLATABLE (CUSTOM) FIELDS: maintain their DB value ...
                    /*} else if ( $get_untraslatable_values && $field->untranslatable ) {
                    		$postdata[$field->name] = $field->value;
                    		$maintain_dbval = true;*/
                } else {
                    if ($field->iscore) {
                        // (posted) CORE FIELDS: if not set maintain their DB value ...
                        if (isset($core_via_post[$field->name])) {
                            if (isset($data[$field->name])) {
                                $postdata[$field->name] = $data[$field->name];
                            } else {
                                $postdata[$field->name] = $field->value;
                                $maintain_dbval = true;
                            }
                            // (not posted) CORE FIELDS: get current value
                        } else {
                            // Get value from the updated item instead of old data
                            $postdata[$field->name] = $this->getCoreFieldValue($field, 0);
//.........这里部分代码省略.........
开发者ID:noxidsoft,项目名称:flexicontent-cck,代码行数:101,代码来源:parentclassitem.php

示例6: save


//.........这里部分代码省略.........
		// ********************************************
		$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();
				else if ($needs_version_reviewal)  $notify_emails = $nConf->emails->notify_existing_reviewal;
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:67,代码来源:_controller.php

示例7: save_import


//.........这里部分代码省略.........
                                // ********************************************
                                $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();
                                                else if ($needs_version_reviewal)  $notify_emails = $nConf->emails->notify_existing_reviewal;
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:67,代码来源:controller.php


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