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


PHP CRM_Contact_BAO_Contact::getThumbSize方法代码示例

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


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

示例1: fileDisplay

 function fileDisplay()
 {
     // Display evidence file
     $postParams = $_POST;
     $fileID = CRM_Core_BAO_File::getEntityFile($postParams['entityTable'], $postParams['entityID']);
     if ($fileID) {
         foreach ($fileID as $k => $v) {
             $fileType = $v['mime_type'];
             $fid = $v['fileID'];
             $eid = $postParams['entityID'];
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 list($path) = CRM_Core_BAO_File::path($fid, $eid, NULL, NULL);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}", FALSE, NULL, TRUE, TRUE);
                 $file_url = "\n              <a href=\"{$url}\" class='crm-image-popup'>\n              <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n              </a>";
                 // for non image files
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fid, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}");
                 $file_url = "<a href=\"{$url}\">{$uri}</a>";
             }
             if (isset($fid)) {
                 $deleteurl = "<div class=file-delete><a class='action-item crm-hover-button' href='javascript:void(0)' id=file_{$fid}>Delete Attached File</a></div>";
                 echo "<div id='del_{$fid}'>{$file_url}{$deleteurl}</div>";
             }
         }
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:30,代码来源:Files.php

示例2: setDefaultsValues


//.........这里部分代码省略.........
             if ($this->_activityId) {
                 CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
             }
         } else {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
         }
     }
     //set custom field defaults
     if ($this->_multiRecordProfile) {
         foreach ($this->_multiRecordFields as $key => $field) {
             $fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
         }
         $defaultValues = array();
         if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
             $defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
             if ($this->_recordExists == TRUE) {
                 $defaultValues = $defaultValues[$this->_recordId];
             } else {
                 $defaultValues = NULL;
             }
         }
         if (!empty($defaultValues)) {
             foreach ($defaultValues as $key => $value) {
                 $name = "custom_{$key}";
                 $htmlType = $this->_multiRecordFields[$name]['html_type'];
                 if ($htmlType != 'File') {
                     if (isset($value)) {
                         CRM_Core_BAO_CustomField::setProfileDefaults($key, $name, $this->_defaults, $this->_id, $this->_mode, $value);
                     } else {
                         $this->_defaults[$name] = "";
                     }
                 }
                 if ($htmlType == 'File') {
                     $entityId = $this->_id;
                     if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                         $entityId = $this->_activityId;
                     }
                     $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key);
                     if ($url) {
                         $customFiles[$name]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                         $deleteExtra = ts("Are you sure you want to delete attached file?");
                         $fileId = $url['file_id'];
                         $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$key}&action=delete");
                         $text = ts("Delete Attached File");
                         $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                         // also delete the required rule that we've set on the form element
                         $this->removeFileRequiredRules($name);
                     }
                 }
             }
         }
     } else {
         foreach ($this->_fields as $name => $field) {
             if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
                 $htmlType = $field['html_type'];
                 if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
                     CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
                 }
                 if ($htmlType == 'File') {
                     $entityId = $this->_id;
                     if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                         $entityId = $this->_activityId;
                     }
                     $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                     if ($url) {
                         $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                         $deleteExtra = ts("Are you sure you want to delete attached file?");
                         $fileId = $url['file_id'];
                         $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                         $text = ts("Delete Attached File");
                         $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                         // also delete the required rule that we've set on the form element
                         $this->removeFileRequiredRules($field['name']);
                     }
                 }
             }
         }
     }
     if (isset($customFiles)) {
         $this->assign('customFiles', $customFiles);
     }
     if ($this->_multiRecordProfile) {
         $this->setDefaults($this->_defaults);
         return;
     }
     if (!empty($this->_defaults['image_URL'])) {
         list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($this->_defaults['image_URL']));
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $this->_defaults['image_URL']);
         $this->removeFileRequiredRules('image_URL');
     }
     if (array_key_exists('contact_sub_type', $this->_defaults) && !empty($this->_defaults['contact_sub_type'])) {
         $this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR));
     }
     $this->setDefaults($this->_defaults);
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Form.php

示例3: getValues


//.........这里部分代码省略.........
                         // values etc, i.e. emulating a profile
                         $fieldType = CRM_Utils_Array::value('field_type', $field);
                         if ($htmlType == 'File') {
                             $entityId = $cid;
                             if (!$cid && $fieldType == 'Activity' && !empty($componentWhere[0][2])) {
                                 $entityId = $componentWhere[0][2];
                             }
                             $fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, $absolute, $additionalWhereClause);
                             $params[$index] = $values[$index] = $fileURL['file_url'];
                         } else {
                             $customVal = NULL;
                             if (isset($dao) && property_exists($dao, 'data_type') && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
                                 $customVal = (int) $details->{$name};
                             } elseif (isset($dao) && property_exists($dao, 'data_type') && $dao->data_type == 'Float') {
                                 $customVal = (double) $details->{$name};
                             } elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
                                 $customVal = $details->{$name};
                             }
                             //CRM-4582
                             if (CRM_Utils_System::isNull($customVal)) {
                                 continue;
                             }
                             $params[$index] = $customVal;
                             $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
                             if ($field['data_type'] == 'ContactReference') {
                                 $params[$index] = $values[$index];
                             }
                             if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
                                 $customFieldName = "{$name}_from";
                             }
                         }
                     } elseif ($name == 'image_URL') {
                         list($width, $height) = getimagesize(CRM_Utils_String::unstupifyUrl($details->{$name}));
                         list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height);
                         $image_URL = '<img src="' . $details->{$name} . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . '  />';
                         $values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->{$name}}\", {$width}, {$height});'>{$image_URL}</a>";
                     } elseif (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) {
                         $values[$index] = CRM_Utils_Date::customFormat($details->{$name});
                         $params[$index] = CRM_Utils_Date::isoToMysql($details->{$name});
                     } else {
                         $dao = '';
                         if ($index == 'Campaign') {
                             $dao = 'CRM_Campaign_DAO_Campaign';
                         } elseif ($index == 'Contribution Page') {
                             $dao = 'CRM_Contribute_DAO_ContributionPage';
                         }
                         if ($dao) {
                             $value = CRM_Core_DAO::getFieldValue($dao, $details->{$name}, 'title');
                         } else {
                             $value = $details->{$name};
                         }
                         $values[$index] = $value;
                     }
                 }
             }
         } elseif (strpos($name, '-') !== FALSE) {
             list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3);
             if (!in_array($fieldName, $multipleFields)) {
                 if ($id == 'Primary') {
                     // fix for CRM-1543
                     // not sure why we'd every use Primary location type id
                     // we need to fix the source if we are using it
                     // $locationTypeName = CRM_Contact_BAO_Contact::getPrimaryLocationType( $cid );
                     $locationTypeName = 1;
                 } else {
                     $locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
开发者ID:rollox,项目名称:civicrm-core,代码行数:67,代码来源:UFGroup.php

示例4: buildCustomFieldData

 /**
  * Build the entity-specific custom data into the group tree on a per-field basis
  *
  * @param object $dao
  *   Object representing the custom field to be populated into the groupTree.
  * @param array $groupTree
  *   (reference) the group tree being build.
  * @param string $table
  *   Table name.
  * @param int $groupID
  *   Custom group ID.
  * @param int $fieldID
  *   Custom field ID.
  */
 public static function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID)
 {
     $column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
     $idName = "{$table}_id";
     $fieldName = "{$table}_{$column}";
     $dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
     if ($dataType == 'File') {
         if (isset($dao->{$fieldName})) {
             $config = CRM_Core_Config::singleton();
             $fileDAO = new CRM_Core_DAO_File();
             $fileDAO->id = $dao->{$fieldName};
             if ($fileDAO->find(TRUE)) {
                 $entityIDName = "{$table}_entity_id";
                 $customValue['id'] = $dao->{$idName};
                 $customValue['data'] = $fileDAO->uri;
                 $customValue['fid'] = $fileDAO->id;
                 $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
                 $customValue['displayURL'] = NULL;
                 $deleteExtra = ts('Are you sure you want to delete attached file.');
                 $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&amp;confirmed=1\'; else return false;"'));
                 $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID), ts('more'), FALSE, 'file.manage.delete', 'File', $fileDAO->id);
                 $customValue['deleteURLArgs'] = CRM_Core_BAO_File::deleteURLArgs($table, $dao->{$entityIDName}, $fileDAO->id);
                 $customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
                 if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
                     $customValue['displayURL'] = $customValue['fileURL'];
                     $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'file_id');
                     $customValue['imageURL'] = str_replace('persist/contribute', 'custom', $config->imageUploadURL) . $fileDAO->uri;
                     list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, NULL, NULL);
                     if ($path && file_exists($path)) {
                         list($imageWidth, $imageHeight) = getimagesize($path);
                         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                         $customValue['imageThumbWidth'] = $imageThumbWidth;
                         $customValue['imageThumbHeight'] = $imageThumbHeight;
                     }
                 }
             }
         } else {
             $customValue = array('id' => $dao->{$idName}, 'data' => '');
         }
     } else {
         $customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
     }
     if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
     }
     if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
     } else {
         $groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:65,代码来源:CustomGroup.php

示例5: setDefaultValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $defaults = $this->_values;
     $params = array();
     if ($this->_action & CRM_Core_Action::ADD) {
         if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
             // set group and tag defaults if any
             if ($this->_gid) {
                 $defaults['group'][$this->_gid] = 1;
             }
             if ($this->_tid) {
                 $defaults['tag'][$this->_tid] = 1;
             }
         }
         if ($this->_contactSubType) {
             $defaults['contact_sub_type'] = $this->_contactSubType;
         }
     } else {
         $currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
         $defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
         foreach ($defaults['email'] as $dontCare => &$val) {
             if (isset($val['signature_text'])) {
                 $val['signature_text_hidden'] = $val['signature_text'];
             }
             if (isset($val['signature_html'])) {
                 $val['signature_html_hidden'] = $val['signature_html'];
             }
         }
         if (CRM_Utils_Array::value('contact_sub_type', $defaults)) {
             $defaults['contact_sub_type'] = $this->_oldSubtypes;
         }
     }
     $this->assign('currentEmployer', CRM_Utils_Array::value('current_employer_id', $defaults));
     // set defaults for blocks ( custom data, address, communication preference, notes, tags and groups )
     foreach ($this->_editOptions as $name => $label) {
         if (!in_array($name, array('Address', 'Notes'))) {
             eval('CRM_Contact_Form_Edit_' . $name . '::setDefaultValues( $this, $defaults );');
         }
     }
     //set address block defaults
     CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
     if (CRM_Utils_Array::value('image_URL', $defaults)) {
         list($imageWidth, $imageHeight) = getimagesize($defaults['image_URL']);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign('imageWidth', $imageWidth);
         $this->assign('imageHeight', $imageHeight);
         $this->assign('imageThumbWidth', $imageThumbWidth);
         $this->assign('imageThumbHeight', $imageThumbHeight);
         $this->assign('imageURL', $defaults['image_URL']);
     }
     //set location type and country to default for each block
     $this->blockSetDefaults($defaults);
     $this->_preEditValues = $defaults;
     return $defaults;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:63,代码来源:Contact.php

示例6: getFileURL

 /**
  * @param int $contactID
  * @param int $cfID
  * @param int $fileID
  * @param bool $absolute
  *
  * @return array
  */
 public static function getFileURL($contactID, $cfID, $fileID = NULL, $absolute = FALSE, $multiRecordWhereClause = NULL)
 {
     if ($contactID) {
         if (!$fileID) {
             $params = array('id' => $cfID);
             $defaults = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
             $columnName = $defaults['column_name'];
             //table name of custom data
             $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $defaults['custom_group_id'], 'table_name', 'id');
             //query to fetch id from civicrm_file
             if ($multiRecordWhereClause) {
                 $query = "SELECT {$columnName} FROM {$tableName} where entity_id = {$contactID} AND {$multiRecordWhereClause}";
             } else {
                 $query = "SELECT {$columnName} FROM {$tableName} where entity_id = {$contactID}";
             }
             $fileID = CRM_Core_DAO::singleValueQuery($query);
         }
         $result = array();
         if ($fileID) {
             $fileType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'mime_type', 'id');
             $result['file_id'] = $fileID;
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileID, 'entity_id', 'id');
                 list($path) = CRM_Core_BAO_File::path($fileID, $entityId, NULL, NULL);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}", $absolute, NULL, TRUE, TRUE);
                 $result['file_url'] = "\n          <a href=\"{$url}\" class='crm-image-popup'>\n          <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n          </a>";
                 // for non image files
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}", $absolute, NULL, TRUE, TRUE);
                 $result['file_url'] = "<a href=\"{$url}\">{$uri}</a>";
             }
         }
         return $result;
     }
 }
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:47,代码来源:CustomField.php

示例7: array


//.........这里部分代码省略.........
         $select = $from = $where = array();
         foreach ($groupTree['info']['tables'] as $table => $fields) {
             $from[] = $table;
             $select[] = "{$table}.id as {$table}_id";
             $select[] = "{$table}.entity_id as {$table}_entity_id";
             foreach ($fields as $column => $dontCare) {
                 $select[] = "{$table}.{$column} as {$table}_{$column}";
             }
             if ($entityID) {
                 $where[] = "{$table}.entity_id = {$entityID}";
             }
         }
         $groupTree['info']['select'] = $select;
         $groupTree['info']['from'] = $from;
         $groupTree['info']['where'] = null;
         if ($entityID) {
             $groupTree['info']['where'] = $where;
             $select = implode(', ', $select);
             // this is a hack to find a table that has some values for this
             // entityID to make the below LEFT JOIN work (CRM-2518)
             $firstTable = null;
             foreach ($from as $table) {
                 $query = "\nSELECT id\nFROM   {$table}\nWHERE  entity_id = {$entityID}\n";
                 $recordExists = CRM_Core_DAO::singleValueQuery($query);
                 if ($recordExists) {
                     $firstTable = $table;
                     break;
                 }
             }
             if ($firstTable) {
                 $fromSQL = $firstTable;
                 foreach ($from as $table) {
                     if ($table != $firstTable) {
                         $fromSQL .= "\nLEFT JOIN {$table} USING (entity_id)";
                     }
                 }
                 $query = "\nSELECT {$select}\n  FROM {$fromSQL}\n WHERE {$firstTable}.entity_id = {$entityID}\n";
                 $dao = CRM_Core_DAO::executeQuery($query);
                 while ($dao->fetch()) {
                     foreach ($groupTree as $groupID => $group) {
                         if ($groupID === 'info') {
                             continue;
                         }
                         $table = $groupTree[$groupID]['table_name'];
                         foreach ($group['fields'] as $fieldID => $dontCare) {
                             $column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
                             $idName = "{$table}_id";
                             $fieldName = "{$table}_{$column}";
                             $dataType = $groupTree[$groupID]['fields'][$fieldID]['data_type'];
                             if ($dataType == 'File') {
                                 if (isset($dao->{$fieldName})) {
                                     require_once 'CRM/Core/DAO/File.php';
                                     $config = CRM_Core_Config::singleton();
                                     $fileDAO = new CRM_Core_DAO_File();
                                     $fileDAO->id = $dao->{$fieldName};
                                     if ($fileDAO->find(true)) {
                                         $entityIDName = "{$table}_entity_id";
                                         $customValue['id'] = $dao->{$idName};
                                         $customValue['data'] = $fileDAO->uri;
                                         $customValue['fid'] = $fileDAO->id;
                                         $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->{$entityIDName}}");
                                         $customValue['displayURL'] = null;
                                         $deleteExtra = ts('Are you sure you want to delete attached file.');
                                         $deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&amp;confirmed=1\'; else return false;"'));
                                         $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $fileDAO->id, 'eid' => $dao->{$entityIDName}, 'fid' => $fieldID));
                                         $customValue['fileName'] = CRM_Utils_File::cleanFileName(basename($fileDAO->uri));
                                         if ($fileDAO->mime_type == "image/jpeg" || $fileDAO->mime_type == "image/pjpeg" || $fileDAO->mime_type == "image/gif" || $fileDAO->mime_type == "image/x-png" || $fileDAO->mime_type == "image/png") {
                                             $customValue['displayURL'] = $customValue['fileURL'];
                                             $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileDAO->id, 'entity_id', 'id');
                                             require_once 'CRM/Core/BAO/File.php';
                                             list($path) = CRM_Core_BAO_File::path($fileDAO->id, $entityId, null, null);
                                             list($imageWidth, $imageHeight) = getimagesize($path);
                                             require_once 'CRM/Contact/BAO/Contact.php';
                                             list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                                             $customValue['imageThumbWidth'] = $imageThumbWidth;
                                             $customValue['imageThumbHeight'] = $imageThumbHeight;
                                         }
                                     }
                                 } else {
                                     $customValue = array('id' => $dao->{$idName}, 'data' => '');
                                 }
                             } else {
                                 $customValue = array('id' => $dao->{$idName}, 'data' => $dao->{$fieldName});
                             }
                             if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
                             }
                             if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
                             } else {
                                 $groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $groupTree;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:CustomGroup.php

示例8: setDefaultsValues

 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  *  
  * @access public 
  * @return void 
  */
 function setDefaultsValues()
 {
     $this->_defaults = array();
     if ($this->_id) {
         CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, true);
     }
     //set custom field defaults
     require_once "CRM/Core/BAO/CustomField.php";
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             $htmlType = $field['html_type'];
             if (!isset($this->_defaults[$name]) || $htmlType == 'File') {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
             }
             if ($htmlType == 'File') {
                 $url = CRM_Core_BAO_CustomField::getFileURL($this->_id, $customFieldID);
                 if ($url) {
                     $customFiles[$field['name']]['displayURL'] = "Attached File : {$url['file_url']}";
                     $deleteExtra = "Are you sure you want to delete attached file ?";
                     $fileId = $url['file_id'];
                     $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$this->_id}&fid={$customFieldID}&action=delete");
                     $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">Delete Attached File</a>";
                 }
             }
         }
     }
     if (isset($customFiles)) {
         $this->assign('customFiles', $customFiles);
     }
     if (CRM_Utils_Array::value('image_URL', $this->_defaults)) {
         list($imageWidth, $imageHeight) = getimagesize($this->_defaults['image_URL']);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $this->_defaults['image_URL']);
     }
     $this->setDefaults($this->_defaults);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:47,代码来源:Form.php

示例9: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     // process url params
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->assign('id', $this->_id);
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     //validate the qfKey
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = NULL;
     }
     $this->assign('searchKey', $qfKey);
     // retrieve the group contact id, so that we can get contact id
     $gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
     if (!$gcid) {
         $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     } else {
         $this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
     }
     if (!$this->_contactId) {
         CRM_Core_Error::statusBounce(ts('We could not find a contact id.'), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     }
     // ensure that the id does exist
     if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) {
         CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     }
     $this->assign('contactId', $this->_contactId);
     // see if we can get prev/next positions from qfKey
     $navContacts = array('prevContactID' => NULL, 'prevContactName' => NULL, 'nextContactID' => NULL, 'nextContactName' => NULL, 'nextPrevError' => 0);
     if ($qfKey) {
         $pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search {$qfKey}", $this->_contactId, $this->_contactId);
         $found = FALSE;
         if (isset($pos['prev'])) {
             $navContacts['prevContactID'] = $pos['prev']['id1'];
             $navContacts['prevContactName'] = $pos['prev']['data'];
             $found = TRUE;
         }
         if (isset($pos['next'])) {
             $navContacts['nextContactID'] = $pos['next']['id1'];
             $navContacts['nextContactName'] = $pos['next']['data'];
             $found = TRUE;
         }
         if (!$found) {
             // seems like we did not find any contacts
             // maybe due to bug CRM-9096
             // however we should account for 1 contact results (which dont have prev next)
             if (!$pos['foundEntry']) {
                 $navContacts['nextPrevError'] = 1;
             }
         }
     }
     $this->assign($navContacts);
     $path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => self::getSearchURL())));
     if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
         //CRM-7265 --time being fix.
         $config = CRM_Core_Config::singleton();
         $image_URL = str_replace('https://', 'http://', $image_URL);
         if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL')) {
             $image_URL = str_replace('http://', 'https://', $image_URL);
         }
         list($imageWidth, $imageHeight) = getimagesize($image_URL);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $image_URL);
     }
     // also store in session for future use
     $session = CRM_Core_Session::singleton();
     $session->set('view.id', $this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
     // check logged in user permission
     self::checkUserPermission($this);
     list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
     $this->assign('displayName', $displayName);
     $this->set('contactType', $contactType);
     $this->set('contactSubtype', $contactSubtype);
     // see if other modules want to add a link activtity bar
     $hookLinks = CRM_Utils_Hook::links('view.contact.activity', 'Contact', $this->_contactId, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
     if (is_array($hookLinks)) {
         $this->assign('hookLinks', $hookLinks);
     }
     // add to recently viewed block
     $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
     $recentOther = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted);
     if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
     }
     if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts') && !$isDeleted) {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:View.php

示例10: getFileURL

 /**
  * Return formatted file URL, like for image file return image url with image icon
  *
  * @param string $path
  *   Absoulte file path
  * @param string $fileType
  * @param string $url
  *   File preview link e.g. https://example.com/civicrm/file?reset=1&filename=image.png&mime-type=image/png
  *
  * @return string $url
  */
 public static function getFileURL($path, $fileType, $url = NULL)
 {
     if (empty($path) || empty($fileType)) {
         return '';
     } elseif (empty($url)) {
         $fileName = basename($path);
         $url = CRM_Utils_System::url('civicrm/file', "reset=1&filename={$fileName}&mime-type={$fileType}");
     }
     switch ($fileType) {
         case 'image/jpeg':
         case 'image/pjpeg':
         case 'image/gif':
         case 'image/x-png':
         case 'image/png':
         case 'image/jpg':
             list($imageWidth, $imageHeight) = getimagesize($path);
             list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
             $url = "<a href=\"{$url}\" class='crm-image-popup'>\n          <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n          </a>";
             break;
         default:
             $url = sprintf('<a href="%s">%s</a>', $url, basename($path));
             break;
     }
     return $url;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:36,代码来源:File.php

示例11: setDefaultsValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return void
  */
 function setDefaultsValues()
 {
     $this->_defaults = array();
     if ($this->_id) {
         if ($this->_isContactActivityProfile) {
             $contactFields = $activityFields = array();
             foreach ($this->_fields as $fieldName => $field) {
                 if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
                     $activityFields[$fieldName] = $field;
                 } else {
                     $contactFields[$fieldName] = $field;
                 }
             }
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $contactFields, $this->_defaults, TRUE);
             if ($this->_activityId) {
                 CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
             }
         } else {
             CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
         }
     }
     //set custom field defaults
     foreach ($this->_fields as $name => $field) {
         if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
             $htmlType = $field['html_type'];
             if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
                 CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
             }
             if ($htmlType == 'File') {
                 $entityId = $this->_id;
                 if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
                     $entityId = $this->_activityId;
                 }
                 $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
                 if ($url) {
                     $customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
                     $deleteExtra = ts("Are you sure you want to delete attached file?");
                     $fileId = $url['file_id'];
                     $deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
                     $text = ts("Delete Attached File");
                     $customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&amp;confirmed=1'; else return false;\">{$text}</a>";
                     // also delete the required rule that we've set on the form element
                     $this->removeFileRequiredRules($field['name']);
                 }
             }
         }
     }
     if (isset($customFiles)) {
         $this->assign('customFiles', $customFiles);
     }
     if (CRM_Utils_Array::value('image_URL', $this->_defaults)) {
         list($imageWidth, $imageHeight) = getimagesize($this->_defaults['image_URL']);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $this->_defaults['image_URL']);
     }
     if (array_key_exists('contact_sub_type', $this->_defaults) && !empty($this->_defaults['contact_sub_type'])) {
         $this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR));
     }
     $this->setDefaults($this->_defaults);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:72,代码来源:Form.php

示例12: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     // process url params
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->assign('id', $this->_id);
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     //validate the qfKey
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = null;
     }
     $this->assign('searchKey', $qfKey);
     // retrieve the group contact id, so that we can get contact id
     $gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
     if (!$gcid) {
         $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
     } else {
         $this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
     }
     if (!$this->_contactId) {
         CRM_Core_Error::statusBounce(ts('We could not find a contact id.'));
     }
     $this->assign('contactId', $this->_contactId);
     $path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => self::getSearchURL())));
     if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
         list($imageWidth, $imageHeight) = getimagesize($image_URL);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $image_URL);
     }
     // also store in session for future use
     $session = CRM_Core_Session::singleton();
     $session->set('view.id', $this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     $this->assign('action', $this->_action);
     // check logged in url permission
     self::checkUserPermission($this);
     list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
     $this->assign('displayName', $displayName);
     $this->set('contactType', $contactType);
     $this->set('contactSubtype', $contactSubtype);
     // see if other modules want to add a link activtity bar
     require_once 'CRM/Utils/Hook.php';
     $hookLinks = CRM_Utils_Hook::links('view.contact.activity', 'Contact', $this->_contactId, CRM_Core_DAO::$_nullObject);
     if (is_array($hookLinks)) {
         $this->assign('hookLinks', $hookLinks);
     }
     // add to recently viewed block
     $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
     $recentOther = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted);
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
     }
     if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts') && !$isDeleted) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', "reset=1&delete=1&cid={$this->_contactId}");
     }
     CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}"), $this->_contactId, $contactType, $this->_contactId, $displayName, $recentOther);
     $this->assign('isDeleted', $isDeleted);
     // set page title
     self::setTitle($this->_contactId, $isDeleted);
     $config = CRM_Core_Config::singleton();
     require_once 'CRM/Core/BAO/UFMatch.php';
     if ($uid = CRM_Core_BAO_UFMatch::getUFId($this->_contactId)) {
         if ($config->userFramework == 'Drupal') {
             $userRecordUrl = CRM_Utils_System::url('user/' . $uid);
         } else {
             if ($config->userFramework == 'Joomla') {
                 $userRecordUrl = $config->userFrameworkBaseURL . 'index2.php?option=com_users&view=user&task=edit&cid[]=' . $uid;
             } else {
                 $userRecordUrl = null;
             }
         }
         $this->assign('userRecordUrl', $userRecordUrl);
         $this->assign('userRecordId', $uid);
     }
     if (CRM_Core_Permission::check('access Contact Dashboard')) {
         $dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
         $this->assign('dashboardURL', $dashboardURL);
     }
     if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && $contactType == 'Organization' && CRM_Core_Permission::check('administer Multiple Organizations')) {
         require_once 'CRM/Contact/BAO/GroupOrganization.php';
         //check is any relationship between the organization and groups
         $groupOrg = CRM_Contact_BAO_GroupOrganization::hasGroupAssociated($this->_contactId);
         if ($groupOrg) {
             $groupOrganizationUrl = CRM_Utils_System::url('civicrm/group', "reset=1&oid={$this->_contactId}");
             $this->assign('groupOrganizationUrl', $groupOrganizationUrl);
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:View.php

示例13: getValues


//.........这里部分代码省略.........
                                                         $dataType = $field['data_type'];
                                                         if ($htmlType == 'File') {
                                                             $fileURL = CRM_Core_BAO_CustomField::getFileURL($cid, $cfID);
                                                             $params[$index] = $values[$index] = $fileURL['file_url'];
                                                         } else {
                                                             $customVal = null;
                                                             if (isset($dao) && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
                                                                 $customVal = (int) $details->{$name};
                                                             } else {
                                                                 if (isset($dao) && $dao->data_type == 'Float') {
                                                                     $customVal = (double) $details->{$name};
                                                                 } else {
                                                                     if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) {
                                                                         $customVal = $details->{$name};
                                                                     }
                                                                 }
                                                             }
                                                             //CRM-4582
                                                             if (CRM_Utils_System::isNull($customVal)) {
                                                                 continue;
                                                             }
                                                             $params[$index] = $customVal;
                                                             $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
                                                             if ($htmlType == 'Autocomplete-Select') {
                                                                 $params[$index] = $values[$index];
                                                             }
                                                             if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
                                                                 $customFieldName = "{$name}_from";
                                                             }
                                                         }
                                                     } else {
                                                         if ($name == 'image_URL') {
                                                             list($width, $height) = getimagesize($details->{$name});
                                                             list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height);
                                                             $image_URL = '<img src="' . $details->{$name} . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . '  />';
                                                             $values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->{$name}}\", {$width}, {$height});'>{$image_URL}</a>";
                                                         } else {
                                                             if (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) {
                                                                 require_once 'CRM/Utils/Date.php';
                                                                 $values[$index] = CRM_Utils_Date::customFormat($details->{$name});
                                                                 $params[$index] = CRM_Utils_Date::isoToMysql($details->{$name});
                                                             } else {
                                                                 $values[$index] = $details->{$name};
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if (strpos($name, '-') !== false) {
                 list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3);
                 if (!in_array($fieldName, $multipleFields)) {
                     if ($id == 'Primary') {
                         // fix for CRM-1543
                         // not sure why we'd every use Primary location type id
                         // we need to fix the source if we are using it
                         // $locationTypeName = CRM_Contact_BAO_Contact::getPrimaryLocationType( $cid );
                         $locationTypeName = 1;
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:UFGroup.php

示例14: preProcess

 /**
  * Heart of the viewing process.
  *
  * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
  */
 public function preProcess()
 {
     // process url params
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->assign('id', $this->_id);
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     //validate the qfKey
     if (!CRM_Utils_Rule::qfKey($qfKey)) {
         $qfKey = NULL;
     }
     $this->assign('searchKey', $qfKey);
     // retrieve the group contact id, so that we can get contact id
     $gcid = CRM_Utils_Request::retrieve('gcid', 'Positive', $this);
     if (!$gcid) {
         $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     } else {
         $this->_contactId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_GroupContact', $gcid, 'contact_id');
     }
     if (!$this->_contactId) {
         CRM_Core_Error::statusBounce(ts('We could not find a contact id.'), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     }
     // ensure that the id does exist
     if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) {
         CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)), CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     }
     $this->assign('contactId', $this->_contactId);
     // see if we can get prev/next positions from qfKey
     $navContacts = array('prevContactID' => NULL, 'prevContactName' => NULL, 'nextContactID' => NULL, 'nextContactName' => NULL, 'nextPrevError' => 0);
     if ($qfKey) {
         $pos = CRM_Core_BAO_PrevNextCache::getPositions("civicrm search {$qfKey}", $this->_contactId, $this->_contactId);
         $found = FALSE;
         if (isset($pos['prev'])) {
             $navContacts['prevContactID'] = $pos['prev']['id1'];
             $navContacts['prevContactName'] = $pos['prev']['data'];
             $found = TRUE;
         }
         if (isset($pos['next'])) {
             $navContacts['nextContactID'] = $pos['next']['id1'];
             $navContacts['nextContactName'] = $pos['next']['data'];
             $found = TRUE;
         }
         $context = CRM_Utils_Array::value('context', $_GET);
         if (!$found) {
             // seems like we did not find any contacts
             // maybe due to bug CRM-9096
             // however we should account for 1 contact results (which dont have prev next)
             if (!$pos['foundEntry']) {
                 $navContacts['nextPrevError'] = 1;
             }
         } elseif ($context) {
             $this->assign('context', $context);
             CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Search Results'), 'url' => CRM_Utils_System::url("civicrm/contact/search/{$context}", array('qfKey' => $qfKey)))));
         }
     }
     $this->assign($navContacts);
     $path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
     CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path)));
     if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) {
         //CRM-7265 --time being fix.
         $config = CRM_Core_Config::singleton();
         $image_URL = str_replace('https://', 'http://', $image_URL);
         if (Civi::settings()->get('enableSSL')) {
             $image_URL = str_replace('http://', 'https://', $image_URL);
         }
         list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($image_URL));
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign("imageWidth", $imageWidth);
         $this->assign("imageHeight", $imageHeight);
         $this->assign("imageThumbWidth", $imageThumbWidth);
         $this->assign("imageThumbHeight", $imageThumbHeight);
         $this->assign("imageURL", $image_URL);
     }
     // also store in session for future use
     $session = CRM_Core_Session::singleton();
     $session->set('view.id', $this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
     // check logged in user permission
     self::checkUserPermission($this);
     list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = self::getContactDetails($this->_contactId);
     $this->assign('displayName', $displayName);
     $this->set('contactType', $contactType);
     // note: there could still be multiple subtypes. We just trimming the outer separator.
     $this->set('contactSubtype', trim($contactSubtype, CRM_Core_DAO::VALUE_SEPARATOR));
     // add to recently viewed block
     $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted');
     $recentOther = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted);
     if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}");
     }
     if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts') && !$isDeleted) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', "reset=1&delete=1&cid={$this->_contactId}");
     }
     CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactId}"), $this->_contactId, $contactType, $this->_contactId, $displayName, $recentOther);
     $this->assign('isDeleted', $isDeleted);
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:View.php

示例15: getFileURL

 static function getFileURL($contactID, $cfID, $fileID = NULL)
 {
     if ($contactID) {
         if (!$fileID) {
             $params = array('id' => $cfID);
             $defaults = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
             $columnName = $defaults['column_name'];
             //table name of custom data
             $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $defaults['custom_group_id'], 'table_name', 'id');
             //query to fetch id from civicrm_file
             $query = "SELECT {$columnName} FROM {$tableName} where entity_id = {$contactID}";
             $fileID = CRM_Core_DAO::singleValueQuery($query);
         }
         $result = array();
         if ($fileID) {
             $fileType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'mime_type', 'id');
             $result['file_id'] = $fileID;
             if ($fileType == "image/jpeg" || $fileType == "image/pjpeg" || $fileType == "image/gif" || $fileType == "image/x-png" || $fileType == "image/png") {
                 $entityId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $fileID, 'entity_id', 'id');
                 require_once 'CRM/Core/BAO/File.php';
                 list($path) = CRM_Core_BAO_File::path($fileID, $entityId, null, null);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}");
                 $result['file_url'] = "<a href='javascript:imagePopUp(\"{$url}\");'><img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/></a>";
             } else {
                 // for non image files
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fileID, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileID}&eid={$contactID}");
                 $result['file_url'] = "<a href=\"{$url}\">{$uri}</a>";
             }
         }
         return $result;
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:36,代码来源:CustomField.php


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