Beispiel #1
0
 /**
  * Action Reschedule
  * Used for drag & drop
  */
 protected function action_reschedule()
 {
     $this->view = 'json';
     $commit = true;
     if (!$this->retrieveCurrentBean('Save')) {
         return;
     }
     $_REQUEST['parent_name'] = $this->currentBean->parent_name;
     $dateField = "date_start";
     if ($this->currentBean->module_dir == "Tasks") {
         $dateField = "date_due";
     }
     if (!empty($_REQUEST['calendar_style']) && $_REQUEST['calendar_style'] == "basic") {
         list($tmp, $time) = explode(" ", $this->currentBean->{$dateField});
         list($date, $tmp) = explode(" ", $_REQUEST['datetime']);
         $_REQUEST['datetime'] = $date . " " . $time;
     }
     $_POST[$dateField] = $_REQUEST['datetime'];
     if ($this->currentBean->module_dir == "Tasks" && !empty($this->currentBean->date_start)) {
         if ($GLOBALS['timedate']->fromUser($_POST['date_due'])->ts < $GLOBALS['timedate']->fromUser($this->currentBean->date_start)->ts) {
             $this->view_object_map['jsonData'] = array('access' => 'no', 'errorMessage' => $GLOBALS['mod_strings']['LBL_DATE_END_ERROR']);
             $commit = false;
         }
     }
     if ($commit) {
         require_once 'include/formbase.php';
         $this->currentBean = populateFromPost("", $this->currentBean);
         $this->currentBean->save();
         $this->currentBean->retrieve($_REQUEST['record']);
         $this->view_object_map['jsonData'] = CalendarUtils::get_sendback_array($this->currentBean);
     }
 }
Beispiel #2
0
 function retrieve($id = -1, $encode = true, $deleted = true)
 {
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'Step2') {
         $this->load_merge_bean($this->merge_bean, false, $id);
     } else {
         parent::retrieve($id, $encode, $deleted);
     }
 }
Beispiel #3
0
 function retrieve($id)
 {
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'Step2') {
         $this->load_merge_bean($this->merge_bean, false, $id);
     } else {
         parent::retrieve($id);
     }
 }
Beispiel #4
0
 function retrieve($id = -1)
 {
     $bean = parent::retrieve($id);
     if ($bean != null) {
         if (!SimpleTeams::checkAccess($bean)) {
             $bean = null;
         }
     }
     return $bean;
 }
 function retrieve($id = NULL, $encode = false)
 {
     $bean = parent::retrieve($id, $encode);
     if ($bean != null) {
         if (!SimpleTeams::checkAccess($bean)) {
             $bean = null;
         }
     }
     return $bean;
 }
Beispiel #6
0
 function retrieve($id = -1, $encode = true, $deleted = true)
 {
     parent::retrieve($id, $encode, $deleted);
     global $timedate;
     $date_start_array = explode(" ", trim($this->date_start));
     if (count($date_start_array) == 2) {
         $this->time_start = $date_start_array[1];
         $this->date_start = $date_start_array[0];
     }
     return $this;
 }
Beispiel #7
0
 function retrieve($id)
 {
     parent::retrieve($id);
     global $timedate;
     $date_start_array = explode(" ", trim($this->date_start));
     if (count($date_start_array) == 2) {
         $this->time_start = $date_start_array[1];
         $this->date_start = $date_start_array[0];
     }
     return $this;
 }
Beispiel #8
0
 function retrieve($id = -1, $encode = true, $deleted = true)
 {
     return parent::retrieve($id, $encode, false);
     //ignore the deleted filter. the table does not have the deleted column in it.
 }
Beispiel #9
0
 function retrieve($id = -99, $encode = true, $deleted = true)
 {
     if ($id == '-99') {
         $this->name = $this->getDefaultCurrencyName();
         $this->symbol = $this->getDefaultCurrencySymbol();
         $this->id = '-99';
         $this->conversion_rate = 1;
         $this->iso4217 = $this->getDefaultISO4217();
         $this->deleted = 0;
         $this->status = 'Active';
         $this->hide = '<!--';
         $this->unhide = '-->';
     } else {
         parent::retrieve($id, $encode, $deleted);
     }
     if (!isset($this->name) || $this->deleted == 1) {
         $this->name = $this->getDefaultCurrencyName();
         $this->symbol = $this->getDefaultCurrencySymbol();
         $this->conversion_rate = 1;
         $this->iso4217 = $this->getDefaultISO4217();
         $this->id = '-99';
         $this->deleted = 0;
         $this->status = 'Active';
         $this->hide = '<!--';
         $this->unhide = '-->';
     }
     return $this;
 }
Beispiel #10
0
/**
 * Populating bean from $_POST
 *
 * @param string $prefix of name of fields
 * @param SugarBean $focus bean
 * @param bool $skipRetrieve do not retrieve data of bean
 * @param bool $checkACL do not update fields if they are forbidden for current user
 * @return SugarBean
 */
function populateFromPost($prefix, &$focus, $skipRetrieve = false, $checkACL = false)
{
    global $current_user;
    if (!empty($_REQUEST[$prefix . 'record']) && !$skipRetrieve) {
        $focus->retrieve($_REQUEST[$prefix . 'record']);
    }
    if (!empty($_POST['assigned_user_id']) && $focus->assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
        $GLOBALS['check_notify'] = true;
    }
    require_once 'include/SugarFields/SugarFieldHandler.php';
    $sfh = new SugarFieldHandler();
    $isOwner = $focus->isOwner($current_user->id);
    $relatedFields = array();
    foreach ($focus->field_defs as $field => $def) {
        if (empty($def['type']) || $def['type'] != 'relate') {
            continue;
        }
        if (empty($def['source']) || $def['source'] != 'non-db') {
            continue;
        }
        if (empty($def['id_name']) || $def['id_name'] == $field) {
            continue;
        }
        $relatedFields[$def['id_name']] = $field;
    }
    foreach ($focus->field_defs as $field => $def) {
        if ($field == 'id' && !empty($focus->id)) {
            // Don't try and overwrite the ID
            continue;
        }
        $type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
        $sf = $sfh->getSugarField($type);
        if ($sf != null) {
            $sf->save($focus, $_POST, $field, $def, $prefix);
        } else {
            $GLOBALS['log']->fatal("Field '{$field}' does not have a SugarField handler");
        }
        /*
                if(isset($_POST[$prefix.$field])) {
        			if(is_array($_POST[$prefix.$field]) && !empty($focus->field_defs[$field]['isMultiSelect'])) {
        				if($_POST[$prefix.$field][0] === '' && !empty($_POST[$prefix.$field][1]) ) {
        					unset($_POST[$prefix.$field][0]);
        				}
        				$_POST[$prefix.$field] = encodeMultienumValue($_POST[$prefix.$field]);	
        			}
        
        			$focus->$field = $_POST[$prefix.$field];
        			/* 
        			 * overrides the passed value for booleans.
        			 * this will be fully deprecated when the change to binary booleans is complete.
        			 /
        			if(isset($focus->field_defs[$prefix.$field]) && $focus->field_defs[$prefix.$field]['type'] == 'bool' && isset($focus->field_defs[$prefix.$field]['options'])) {
        				$opts = explode("|", $focus->field_defs[$prefix.$field]['options']);
        				$bool = $_POST[$prefix.$field];
        
        				if(is_int($bool) || ($bool === "0" || $bool === "1" || $bool === "2")) {
        					// 1=on, 2=off
        					$selection = ($_POST[$prefix.$field] == "0") ? 1 : 0;
        				} elseif(is_bool($_POST[$prefix.$field])) {
        					// true=on, false=off
        					$selection = ($_POST[$prefix.$field]) ? 0 : 1;
        				}
        				$focus->$field = $opts[$selection];
        			}
        		} else if(!empty($focus->field_defs[$field]['isMultiSelect']) && !isset($_POST[$prefix.$field]) && isset($_POST[$prefix.$field . '_multiselect'])) {
        			$focus->$field = '';
        		}
        */
    }
    foreach ($focus->additional_column_fields as $field) {
        if (isset($_POST[$prefix . $field])) {
            $value = $_POST[$prefix . $field];
            $focus->{$field} = $value;
        }
    }
    return $focus;
}
Beispiel #11
0
 /**
  * @see SugarBean::retrieve()
  */
 public function retrieve($id = -1, $encode = true, $deleted = true)
 {
     $returnVal = parent::retrieve($id, $encode, $deleted);
     if (!$returnVal instanceof $this) {
         return $returnVal;
     }
     if ($this->source == 'tab' && $this->delimiter == '') {
         $this->delimiter = "\t";
     }
     return $this;
 }
Beispiel #12
0
 function retrieve($id = -1, $encode = false, $deleted = true)
 {
     $ret = parent::retrieve($id, $encode, $deleted);
     return $ret;
 }
Beispiel #13
0
 /**
  * retrieves I-E bean
  * @param string id
  * @return object Bean
  */
 function retrieve($id, $encode = true, $deleted = true)
 {
     $ret = parent::retrieve($id, $encode, $deleted);
     // if I-E bean exist
     if (!is_null($ret)) {
         $this->retrieveMailBoxFolders();
     }
     return $ret;
 }
 function retrieve($id = -1, $encode = true)
 {
     global $locale;
     $ret_val = parent::retrieve($id, $encode);
     // make a properly formatted first and last name
     $this->_create_proper_name_field();
     return $ret_val;
 }
Beispiel #15
0
 /**
  * retrieve
  *
  * returns currency object for given id, or base if none given
  *
  * @param  string   $id      currency id
  * @param  boolean  $encode
  * @param  boolean  $deleted
  * @return object   currency object, base currency if id is not found
  */
 function retrieve($id, $encode = true, $deleted = true)
 {
     if (empty($id) || $id == '-99') {
         $this->setBaseCurrency();
     } else {
         parent::retrieve($id, $encode, $deleted);
     }
     if (!isset($this->name) || $this->deleted == 1) {
         $this->setBaseCurrency();
     }
     return $this;
 }
Beispiel #16
0
 function retrieve($id = -1, $encode = true, $deleted = true)
 {
     parent::retrieve($id, $encode, $deleted);
     if ($this->id != '') {
         $arrayList = json_decode(html_entity_decode($this->listfields, ENT_QUOTES, 'UTF-8'), true);
         foreach ($arrayList as $listFieldData) {
             $this->listFieldArrayById[$listFieldData['fieldid']] = $listFieldData;
         }
     }
     return $this;
 }
 /**
  * retrieves an User bean
  * preformat name & full_name attribute with first/last
  * loads User's preferences
  * 
  * @param string id ID of the User
  * @param bool encode encode the result
  * @return object User bean
  * @return null null if no User found
  */
 function retrieve($id, $encode = true)
 {
     global $locale;
     $ret = SugarBean::retrieve($id, $encode);
     if ($ret) {
         // make a properly formatted first and last name
         $this->_create_proper_name_field();
         if (isset($_SESSION)) {
             $this->loadPreferences();
         }
     }
     return $ret;
 }
 function retrieve($id = -1, $encode = true)
 {
     $ret_val = parent::retrieve($id, $encode);
     // make a properly formatted first and last name
     $full_name = '';
     if (!empty($this->first_name)) {
         $full_name = $this->first_name;
     }
     if (!empty($full_name) && !empty($this->last_name)) {
         $full_name .= ' ' . $this->last_name;
     } elseif (empty($full_name) && !empty($this->last_name)) {
         $full_name = $this->last_name;
     }
     $this->name = $full_name;
     return $ret_val;
 }
Beispiel #19
0
 /**
  * Wrapper around formatBean based on Result
  *
  * @param \RestService $api
  * @param Result       $result
  *
  * @return array
  */
 protected function formatBeanFromResult(\RestService $api, array $args, \Elastica\Result $result, SugarBean $bean)
 {
     // pass in field list from available data fields on result
     if (empty($args['fields'])) {
         $args['fields'] = array_keys($result->getSource());
     }
     $bean->retrieve($result->getId());
     return $this->formatBean($api, $args, $bean);
 }
Beispiel #20
0
 /**
  * retrieves I-E bean
  * @param string id
  * @return object Bean
  */
 function retrieve($id, $encode = true, $deleted = true)
 {
     $ret = parent::retrieve($id, $encode, $deleted);
     // if I-E bean exist
     if (!is_null($ret)) {
         $this->email_password = blowfishDecode(blowfishGetKey('InboundEmail'), $this->email_password);
         $this->retrieveMailBoxFolders();
     }
     return $ret;
 }
Beispiel #21
0
 function retrieve($id, $encode = false)
 {
     $ret = parent::retrieve($id, $encode);
     return $ret;
 }
Beispiel #22
0
 /**
  * custom override of retrieve function to disable the date formatting and reset it again after the bean has been retrieved.
  *
  * @param string $id
  * @param bool $encode
  * @param bool $deleted
  * @return null|SugarBean
  */
 public function retrieve($id, $encode = false, $deleted = true)
 {
     global $disable_date_format;
     $previous_disable_date_format = $disable_date_format;
     $disable_date_format = 1;
     $ret = parent::retrieve($id, $encode, $deleted);
     $disable_date_format = $previous_disable_date_format;
     return $ret;
 }
Beispiel #23
0
 function retrieveSavedSearch($id)
 {
     parent::retrieve($id);
     $this->contents = unserialize(base64_decode($this->contents));
 }
Beispiel #24
0
 /**
  * This method operates on all related record, takes action based on cardinality of the relationship.
  * one-to-one, one-to-many: update the rhs table's parent id with null
  * many-to-one: update the lhs table's parent-id with null.
  * many-to-many: delete rows from the link table. related table must have deleted and date_modified column.
  * If related_id is null, the methods assumes that the parent bean (whose id is passed) is being deleted.
  * If both id and related_id are passed, the method unlinks a single relationship.
  * parameters: id of the bean being deleted.
  *
  * @param string $id
  * @param string $related_id
  *
  * @return null
  */
 public function delete($id, $related_id = '')
 {
     Log::debug(sprintf("delete called with these parameter values. id=%s, related_id=%s", $id, $related_id));
     $_relationship =& $this->_relationship;
     $_bean =& $this->_bean;
     $bean_is_lhs = $this->_get_bean_position();
     if (!isset($bean_is_lhs)) {
         Log::debug("Invalid relationship parameters. Exiting..");
         return null;
     }
     if ($_relationship->relationship_type == 'one-to-many' or $_relationship->relationship_type == 'one-to-one') {
         if ($bean_is_lhs) {
             // update rhs_table set rhs_key = null, relation_column_name = null where rhs_key= this_bean_id
             $query = 'UPDATE ' . $_relationship->rhs_table . ' SET ' . $_relationship->rhs_key . "=NULL, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
             if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
                 $query .= ',' . $_relationship->relationship_role_column . "= NULL ";
                 $query .= ' WHERE ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "' AND ";
             } else {
                 $query .= ' WHERE ';
             }
             $query .= $_relationship->rhs_key . "= '" . $id . "' ";
             // restrict to one row if related_id is passed.
             if (!empty($related_id)) {
                 $query .= " AND " . $_relationship->rhs_table . ".id='" . $related_id . "'";
             }
         } else {
             // do nothing because the row that stores the relationship keys is being deleted.
             // todo log an error message here.
             // if this is the case and related_id is passed then log a message asking the user
             // to clear the relationship using the bean.
         }
     }
     if ($_relationship->relationship_type == 'many-to-one') {
         // do nothing because the row that stores the relationship keys is being deleted.
         // todo log an error message here.
         // if this is the case and related_id is passed then log a message asking the user
         // to clear the relationship using the bean.
     }
     if ($_relationship->relationship_type == 'many-to-many') {
         $use_bean_is_lhs = isset($_REQUEST['ajaxSubpanel']) || $this->_swap_sides !== true;
         $query = 'UPDATE ' . $_relationship->join_table . " SET deleted=1, date_modified='" . $GLOBALS['timedate']->nowDb() . "'";
         if ($bean_is_lhs && $use_bean_is_lhs) {
             if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
                 if (empty($related_id)) {
                     $query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' or " . $_relationship->join_key_rhs . "='" . $id . "')";
                 } else {
                     $query .= " WHERE (" . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "') OR (" . $_relationship->join_key_rhs . "='" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "')";
                 }
             } else {
                 if (empty($related_id)) {
                     $query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "'";
                 } else {
                     $query .= " WHERE " . $_relationship->join_key_lhs . "= '" . $id . "' AND " . $_relationship->join_key_rhs . "= '" . $related_id . "'";
                 }
             }
         } else {
             if (!empty($this->_relationship->reverse) && ($this->_relationship->reverse == true or $this->_relationship->reverse == 1)) {
                 if (empty($related_id)) {
                     $query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' or " . $_relationship->join_key_lhs . "='" . $id . "')";
                 } else {
                     $query .= " WHERE (" . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "='" . $related_id . "') OR (" . $_relationship->join_key_lhs . "='" . $id . "' AND " . $_relationship->join_key_rhs . "='" . $related_id . "')";
                 }
             } else {
                 if (empty($related_id)) {
                     $query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "'";
                 } else {
                     $query .= " WHERE " . $_relationship->join_key_rhs . "= '" . $id . "' AND " . $_relationship->join_key_lhs . "= '" . $related_id . "'";
                 }
             }
             if (!empty($_relationship->relationship_role_column) && !empty($_relationship->relationship_role_column_value)) {
                 $query .= ' AND ' . $_relationship->relationship_role_column . "= '" . $_relationship->relationship_role_column_value . "'";
             }
         }
     }
     // if query string is not empty execute it.
     if (isset($query)) {
         Log::fatal('Link.Delete:Delete Query: ' . $query);
         $this->_db->query($query, true);
     }
     $custom_logic_arguments = [];
     $custom_logic_arguments['id'] = $id;
     $custom_logic_arguments['related_id'] = $related_id;
     $custom_reverse_arguments = [];
     $custom_reverse_arguments['related_id'] = $id;
     $custom_reverse_arguments['id'] = $related_id;
     if ($bean_is_lhs) {
         $custom_logic_arguments['module'] = $this->_relationship->lhs_module;
         $custom_logic_arguments['related_module'] = $this->_relationship->rhs_module;
         $custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
     } else {
         $custom_logic_arguments['module'] = $this->_relationship->rhs_module;
         $custom_logic_arguments['related_module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['module'] = $this->_relationship->lhs_module;
         $custom_reverse_arguments['related_module'] = $this->_relationship->rhs_module;
     }
     if (empty($this->_bean->id)) {
         $this->_bean->retrieve($id);
     }
     $this->_bean->call_custom_logic('after_relationship_delete', $custom_logic_arguments);
     // NOW THE REVERSE WAY SINCE A RELATIONSHIP TAKES TWO
     global $beanList;
     if (isset($beanList[$custom_logic_arguments['related_module']])) {
         $class = $beanList[$custom_logic_arguments['related_module']];
         if (!empty($class)) {
             /** @var SugarBean $rbean */
             $rbean = new $class();
             $rbean->retrieve(empty($related_id) ? $id : $related_id);
             $rbean->call_custom_logic('after_relationship_delete', $custom_reverse_arguments);
         }
     }
 }
Beispiel #25
0
 function retrieve($id = -1, $encode = true)
 {
     $ret_val = parent::retrieve($id, $encode);
     $this->emailAddress->handleLegacyRetrieve($this);
     return $ret_val;
 }
 function retrieve($id = -1, $encode = true)
 {
     $ret_val = parent::retrieve($id, $encode);
     $this->_create_proper_name_field();
     return $ret_val;
 }
Beispiel #27
0
 function retrieve($id, $encoded = true, $deleted = true)
 {
     // cn: bug 11915, return SugarBean's retrieve() call bean instead of $this
     $ret = parent::retrieve($id, $encoded, $deleted);
     if ($ret) {
         $ret->retrieveEmailText();
         $ret->retrieveEmailAddresses();
         $ret->raw_source = to_html($ret->safeText(from_html($ret->raw_source)));
         $ret->description = to_html($ret->safeText(from_html($ret->description)));
         $ret->description_html = $ret->safeText($ret->description_html);
         $ret->date_start = '';
         $ret->time_start = '';
         $dateSent = explode(' ', $ret->date_sent);
         if (!empty($dateSent)) {
             $ret->date_start = $dateSent[0];
             if (isset($dateSent[1])) {
                 $ret->time_start = $dateSent[1];
             }
         }
         // for Email 2.0
         foreach ($ret as $k => $v) {
             $this->{$k} = $v;
         }
     }
     return $ret;
 }
 /**
  * Given a record id load the bean. This bean is accessible from any sub controllers.
  */
 public function loadBean()
 {
     if (!empty($GLOBALS['beanList'][$this->module])) {
         $class = $GLOBALS['beanList'][$this->module];
         if (!empty($GLOBALS['beanFiles'][$class])) {
             require_once $GLOBALS['beanFiles'][$class];
             $this->bean = new $class();
             if (!empty($this->record)) {
                 $this->bean->retrieve($this->record);
                 if ($this->bean) {
                     $GLOBALS['FOCUS'] = $this->bean;
                 }
             }
         }
     }
 }
 /**
  * retrieves I-E bean
  * @param string id
  * @return object Bean
  */
 function retrieve($id)
 {
     $ret = parent::retrieve($id);
     $this->email_password = blowfishDecode(blowfishGetKey('InboundEmail'), $this->email_password);
     $this->retrieveMailBoxFolders();
     return $ret;
 }
 function retrieve($id = -1, $encode = true)
 {
     global $locale;
     $ret_val = parent::retrieve($id, $encode);
     // make a properly formatted first and last name
     $full_name = $locale->getLocaleFormattedName($this->first_name, $this->last_name, $this->salutation);
     $this->name = $full_name;
     $this->full_name = $full_name;
     return $ret_val;
 }