Пример #1
0
 public function import()
 {
     $aflag = Activity::isEnabled();
     Activity::disable();
     // do we have a currency_id field
     $this->currencyFieldPosition = array_search('currency_id', $this->importColumns);
     //catch output including notices and warnings so import process can run to completion
     $output = '';
     ob_start();
     foreach ($this->importSource as $row) {
         $this->importRow($row);
     }
     //if any output was produced, then display it as an error.
     //first, replace more than one consecutive spaces with a single space.  This is to condense
     //multiple line/row errors and prevent miscount of rows in list navigation UI
     $output = ob_get_clean();
     if (!empty($output)) {
         $output = preg_replace('/\\s+/', ' ', trim($output));
         $this->importSource->writeError('Execution', 'Execution Error', $output);
     }
     // save mapping if requested
     if (isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') {
         $this->saveMappingFile();
     }
     $this->importSource->writeStatus();
     if ($aflag) {
         Activity::enable();
     }
     //All done, remove file.
 }
Пример #2
0
 /**
  * Logic hook arbiter for activity streams.
  *
  * @param  SugarBean $bean
  * @param  string    $event
  * @param  array     $args
  */
 public function eventDispatcher(SugarBean $bean, $event, $args)
 {
     if (Activity::isEnabled()) {
         $activity = BeanFactory::getBean('Activities');
         $eventTriggered = false;
         if ($event == 'after_save' && self::isEnabledForModule($bean->module_name)) {
             $eventTriggered = $this->createOrUpdate($bean, $args, $activity);
         } elseif ($event == 'after_relationship_add' && $this->isValidLink($args)) {
             $eventTriggered = $this->link($args, $activity);
         } elseif ($event == 'after_relationship_delete' && $this->isValidLink($args)) {
             $eventTriggered = $this->unlink($args, $activity);
         }
         // Add the job queue process to add rows to the activities_users
         // join table. This has been moved to the job queue as it's a
         // potentially slow operation.
         if ($eventTriggered) {
             $subscriptionsBeanName = BeanFactory::getBeanName('Subscriptions');
             $subscriptionsBeanName::processSubscriptions($bean, $activity, $args, array('disable_row_level_security' => true));
         }
     }
 }
Пример #3
0
 /**
  * This function should be overridden in each module.  It marks an item as deleted.
  *
  * If it is not overridden, then marking this type of item is not allowed
  */
 public function mark_deleted($id)
 {
     global $current_user;
     $date_modified = $GLOBALS['timedate']->nowDb();
     if (isset($_SESSION['show_deleted'])) {
         $this->mark_undeleted($id);
     } else {
         // Ensure that Activity Messages do not occur in the context of a Delete action (e.g. unlink)
         // and do so for all nested calls within the Top Level Delete Context
         $opflag = static::enterOperation('delete');
         $aflag = Activity::isEnabled();
         Activity::disable();
         // call the custom business logic
         $custom_logic_arguments['id'] = $id;
         $this->call_custom_logic("before_delete", $custom_logic_arguments);
         $this->deleted = 1;
         $this->mark_relationships_deleted($id);
         if (isset($this->field_defs['modified_user_id'])) {
             if (!empty($current_user)) {
                 $this->modified_user_id = $current_user->id;
             } else {
                 $this->modified_user_id = 1;
             }
             $query = "UPDATE {$this->table_name} set deleted=1, date_modified = '{$date_modified}',\n                            modified_user_id = '{$this->modified_user_id}' where id='{$id}'";
             if ($this->isFavoritesEnabled()) {
                 SugarFavorites::markRecordDeletedInFavorites($id, $date_modified, $this->modified_user_id);
             }
         } else {
             $query = "UPDATE {$this->table_name} set deleted=1 , date_modified = '{$date_modified}' where id='{$id}'";
             if ($this->isFavoritesEnabled()) {
                 SugarFavorites::markRecordDeletedInFavorites($id, $date_modified);
             }
         }
         $this->db->query($query, true, "Error marking record deleted: ");
         // Take the item off the recently viewed lists
         $tracker = BeanFactory::getBean('Trackers');
         $tracker->makeInvisibleForAll($id);
         require_once 'include/SugarSearchEngine/SugarSearchEngineFactory.php';
         $searchEngine = SugarSearchEngineFactory::getInstance();
         $searchEngine->delete($this);
         SugarRelationship::resaveRelatedBeans();
         // call the custom business logic
         $this->call_custom_logic("after_delete", $custom_logic_arguments);
         if (static::leaveOperation('delete', $opflag) && $aflag) {
             Activity::enable();
         }
     }
 }
Пример #4
0
 /**
  * Is activity Enabled ?
  * @return    boolean
  */
 public function isActivityEnabled()
 {
     // Return false if the class doesn't exists. On older Sugar version.
     if (class_exists('Activity')) {
         return \Activity::isEnabled();
     }
     return false;
 }