Esempio n. 1
1
 /**
  * Class constructor.
  *
  * @param null $title
  * @param bool|int $action
  * @param bool $modal
  *
  * @throws \Exception
  */
 public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE)
 {
     parent::__construct($title, $modal, NULL, FALSE, TRUE);
     // New:            civicrm/mailing/send?reset=1
     // Re-use:         civicrm/mailing/send?reset=1&mid=%%mid%%
     // Continue:       civicrm/mailing/send?reset=1&mid=%%mid%%&continue=true
     $mid = CRM_Utils_Request::retrieve('mid', 'Positive');
     $continue = CRM_Utils_Request::retrieve('continue', 'String');
     if (!$mid) {
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/new'));
     }
     if ($mid && $continue) {
         //CRM-15979 - check if abtest exist for mailing then redirect accordingly
         $abtest = CRM_Mailing_BAO_MailingAB::getABTest($mid);
         if (!empty($abtest) && !empty($abtest->id)) {
             $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id);
         } else {
             $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mid);
         }
         CRM_Utils_System::redirect($redirect);
     }
     if ($mid && !$continue) {
         $clone = civicrm_api3('Mailing', 'clone', array('id' => $mid));
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id']));
     }
 }
 function run()
 {
     $session = CRM_Core_Session::singleton();
     $apiURL = "https://graph.facebook.com/v2.3";
     $redirect_uri = rawurldecode(CRM_Utils_System::url('civicrm/civisocial/facebookcallback', NULL, TRUE));
     // Retreive client_id and client_secret from settings
     $is_enabled = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'enable_facebook'));
     if (!$is_enabled) {
         die("Backend not enabled.");
     }
     $client_secret = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_secret'));
     $client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_app_id'));
     // Facebook sends a code to the callback url, this is further used to acquire
     // access token from facebook, which is needed to get all the data from facebook
     if (array_key_exists('code', $_GET)) {
         $facebook_code = $_GET['code'];
     } else {
         die("FACEBOOK FATAL: the request returned without the code. Please try loging in again.");
     }
     // Get the access token from facebook for the user
     $access_token = "";
     $access_token_response = $this->get_response($apiURL, "oauth/access_token", FALSE, array("client_id" => $client_id, "client_secret" => $client_secret, "code" => $facebook_code, "redirect_uri" => $redirect_uri));
     if (array_key_exists("error", $access_token_response)) {
         die($access_token_response["error"]);
         $access_token = "";
     } else {
         $access_token = $access_token_response["access_token"];
     }
     $user_data_response = $this->get_response($apiURL, "me", FALSE, array("access_token" => $access_token));
     $contact_id = CRM_Civisocial_BAO_CivisocialUser::handle_facebook_data($user_data_response);
     $this->assign('status', $contact_id);
     $session->set('userID', $contact_id);
     parent::run();
 }
 /**
  * Method processAction to execute the action
  *
  * @param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @access public
  *
  */
 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $contactId = $triggerData->getContactId();
     $processContact = false;
     // retrieve contact type of contact
     $contactParams = array('id' => $contactId, 'return' => 'contact_type');
     $contactType = civicrm_api3('Contact', 'Getvalue', $contactParams);
     // retrieve contact type Donor and only execute if the same
     $donorType = civicrm_api3('ContactType', 'Getsingle', array('name' => 'Donor'));
     try {
         switch ($contactType) {
             case 'Individual':
                 if ($donorType['parent_id'] = 1) {
                     $processContact = true;
                 }
                 break;
             case 'Household':
                 if ($donorType['parent_id'] = 2) {
                     $processContact = true;
                 }
                 break;
             case 'Organization':
                 if ($donorType['parent_id'] = 3) {
                     $processContact = true;
                 }
                 break;
         }
     } catch (CiviCRM_API3_Exception $ex) {
     }
     if ($processContact) {
         $newParams = array('id' => $contactId, 'contact_sub_type' => 'Donor');
         civicrm_api3('Contact', 'Create', $newParams);
     }
 }
Esempio n. 4
0
 /**
  * @return array
  */
 public function checkOptionGroupValues()
 {
     $messages = array();
     $problemValues = array();
     $optionGroups = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'data_type' => array('IS NOT NULL' => 1), 'options' => array('limit' => 0)));
     if ($optionGroups['count'] > 0) {
         foreach ($optionGroups['values'] as $optionGroup) {
             $values = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroup['id']);
             if (count($values) > 0) {
                 foreach ($values as $value) {
                     $validate = CRM_Utils_Type::validate($value['value'], $optionGroup['data_type'], FALSE);
                     if (!$validate) {
                         $problemValues[] = array('group_name' => $optionGroup['title'], 'value_name' => $value['label']);
                     }
                 }
             }
         }
     }
     if (!empty($problemValues)) {
         $strings = '';
         foreach ($problemValues as $problemValue) {
             $strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', array(1 => $problemValue['group_name'], 2 => $problemValue['value_name']));
         }
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
     <p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') . $strings . ts('</tbody></table></p>'), ts('Option Values with problematic Values'), \Psr\Log\LogLevel::NOTICE, 'fa-server');
     }
     return $messages;
 }
/**
 * Implementation of hook_civicrm_pageRun
 *
 * Handler for pageRun hook.
 */
function mailjet_civicrm_pageRun(&$page)
{
    if (get_class($page) == 'CRM_Mailing_Page_Report') {
        $mailingId = $page->_mailing_id;
        $mailingJobs = civicrm_api3('MailingJob', 'get', $params = array('mailing_id' => $mailingId));
        $stats = array('BlockedCount' => 0, 'BouncedCount' => 0, 'ClickedCount' => 0, 'DeliveredCount' => 0, 'OpenedCount' => 0, 'ProcessedCount' => 0, 'QueuedCount' => 0, 'SpamComplaintCount' => 0, 'UnsubscribedCount' => 0);
        foreach ($mailingJobs['values'] as $key => $job) {
            if ($job['job_type'] == 'child') {
                $jobId = $key;
                require_once 'packages/mailjet-0.3/php-mailjet-v3-simple.class.php';
                // Create a new Mailjet Object
                $mj = new Mailjet(MAILJET_API_KEY, MAILJET_SECRET_KEY);
                $mj->debug = 0;
                $mailJetParams = array('method' => 'VIEW', 'unique' => CRM_Mailjet_BAO_Event::getMailjetCustomCampaignId($jobId));
                $response = $mj->campaign($mailJetParams);
                $page->assign('mailjet_params', $mailJetParams);
                if (!empty($response)) {
                    if ($response->Count == 1) {
                        $campaign = $response->Data[0];
                        $mailJetParams = array('method' => 'VIEW', 'unique' => $campaign->ID);
                        $response = $mj->campaignstatistics($mailJetParams);
                        if ($response->Count == 1) {
                            $stats = sumUpStats($stats, get_object_vars($response->Data[0]));
                        }
                    }
                }
            }
        }
        $page->assign('mailjet_stats', $stats);
        CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Mailjet/Page/Report.tpl'));
    }
}
Esempio n. 6
0
 /**
  * @param string $component
  *
  * @return bool|void
  */
 public function main($component = 'contribute')
 {
     //we only get invoice num as a key player from payment gateway response.
     //for ARB we get x_subscription_id and x_subscription_paynum
     $x_subscription_id = $this->retrieve('x_subscription_id', 'String');
     $ids = $objects = $input = array();
     if ($x_subscription_id) {
         //Approved
         $input['component'] = $component;
         // load post vars in $input
         $this->getInput($input, $ids);
         // load post ids in $ids
         $this->getIDs($ids, $input);
         // This is an unreliable method as there could be more than one instance.
         // Recommended approach is to use the civicrm/payment/ipn/xx url where xx is the payment
         // processor id & the handleNotification function (which should call the completetransaction api & by-pass this
         // entirely). The only thing the IPN class should really do is extract data from the request, validate it
         // & call completetransaction or call fail? (which may not exist yet).
         $paymentProcessorTypeID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'AuthNet', 'id', 'name');
         $paymentProcessorID = (int) civicrm_api3('PaymentProcessor', 'getvalue', array('is_test' => 0, 'options' => array('limit' => 1), 'payment_processor_type_id' => $paymentProcessorTypeID, 'return' => 'id'));
         if (!$this->validateData($input, $ids, $objects, TRUE, $paymentProcessorID)) {
             return FALSE;
         }
         if ($component == 'contribute' && $ids['contributionRecur']) {
             // check if first contribution is completed, else complete first contribution
             $first = TRUE;
             if ($objects['contribution']->contribution_status_id == 1) {
                 $first = FALSE;
             }
             return $this->recur($input, $ids, $objects, $first);
         }
     }
     return TRUE;
 }
Esempio n. 7
0
/**
 * Register with a remote application and create a new connection.
 *
 * One should generally identify an application using the app_guid.
 * However, if you need to test a new/experimental application, then
 * disable CIVICRM_CXN_CA and specify app_meta_url.
 *
 * @param array $params
 *   Array with keys:
 *   - app_guid: The unique identifer of the target application.
 *   - app_meta_url: The URL for the application's metadata.
 * @return array
 * @throws Exception
 */
function civicrm_api3_cxn_register($params)
{
    if (!empty($params['app_meta_url'])) {
        list($status, $json) = CRM_Utils_HttpClient::singleton()->get($params['app_meta_url']);
        if (CRM_Utils_HttpClient::STATUS_OK != $status) {
            throw new API_Exception("Failed to download appMeta. (Bad HTTP response)");
        }
        $appMeta = json_decode($json, TRUE);
        if (empty($appMeta)) {
            throw new API_Exception("Failed to download appMeta. (Malformed)");
        }
    } elseif (!empty($params['app_guid'])) {
        $appMeta = civicrm_api3('CxnApp', 'getsingle', array('appId' => $params['app_guid']));
    }
    if (empty($appMeta) || !is_array($appMeta)) {
        throw new API_Exception("Missing expected parameter: app_guid");
    }
    \Civi\Cxn\Rpc\AppMeta::validate($appMeta);
    try {
        /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
        $client = \Civi::service('cxn_reg_client');
        list($cxnId, $result) = $client->register($appMeta);
        CRM_Cxn_BAO_Cxn::updateAppMeta($appMeta);
    } catch (Exception $e) {
        CRM_Cxn_BAO_Cxn::updateAppMeta($appMeta);
        throw $e;
    }
    return $result;
}
Esempio n. 8
0
 /**
  * Load needed JS, CSS and settings for the backend Volunteer Management UI
  */
 public static function addResources($entity_id, $entity_table)
 {
     static $loaded = FALSE;
     if ($loaded) {
         return;
     }
     $loaded = TRUE;
     $config = CRM_Core_Config::singleton();
     $ccr = CRM_Core_Resources::singleton();
     // Vendor libraries
     $ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE);
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header');
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE);
     // Our stylesheet
     $ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css');
     // Add all scripts for our js app
     $weight = 0;
     $baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/';
     // This glob pattern will recurse the js directory up to 4 levels deep
     foreach (glob($baseDir . 'js/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) {
         $fileName = substr($file, strlen($baseDir));
         $ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++);
     }
     // Add our template
     CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
     CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
     // Fetch event so we can set the default start time for needs
     // FIXME: Not the greatest for supporting non-events
     $entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id));
     // Static variables
     $ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat)));
     // Check for problems
     _volunteer_civicrm_check_resource_url();
 }
Esempio n. 9
0
 public function preProcess()
 {
     parent::preProcess();
     list($groupId, $ssId) = $this->createHiddenGroup();
     $mailing = civicrm_api3('Mailing', 'create', array('name' => "", 'campaign_id' => NULL, 'replyto_email' => "", 'subject' => "", 'body_html' => "", 'body_text' => "", 'groups' => array('include' => array($groupId), 'exclude' => array(), 'base' => array()), 'mailings' => array('include' => array(), 'exclude' => array())));
     CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id']));
 }
Esempio n. 10
0
 function getBackendURI()
 {
     $backendURI = NULL;
     $path = CRM_Utils_System::currentPath();
     if (false !== strpos($path, '..')) {
         die("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
     }
     $path = split('/', $path);
     if (!CRM_Utils_Array::value(3, $path)) {
         die("BACKEND ERROR: No backend found in request");
     } else {
         $backend = CRM_Utils_Array::value(3, $path);
         if ("facebook" == $backend) {
             $enabled = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'enable_facebook'));
             if ($enabled) {
                 $facebook_client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_app_id'));
                 $backendURI = "https://www.facebook.com/dialog/oauth?";
                 $backendURI .= "client_id=" . $facebook_client_id;
                 $backendURI .= "&redirect_uri=" . $this->getRedirectURI("facebook");
             }
         } else {
             if ("googleplus" == $backend) {
                 $enabled = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'enable_googleplus'));
                 if ($enabled) {
                     $googleplus_client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'google_plus_key'));
                     $backendURI = "https://accounts.google.com/o/oauth2/auth?scope=email%20profile&response_type=code&";
                     $backendURI .= "client_id=" . $googleplus_client_id;
                     $backendURI .= "&redirect_uri=" . $this->getRedirectURI("googleplus");
                 }
             }
         }
     }
     return $backendURI;
 }
Esempio n. 11
0
 /**
  * Add the membership Payments.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, 'MembershipPayment', CRM_Utils_Array::value('id', $params), $params);
     $dao = new CRM_Member_DAO_MembershipPayment();
     $dao->copyValues($params);
     $dao->id = CRM_Utils_Array::value('id', $params);
     //Fixed for avoiding duplicate entry error when user goes
     //back and forward during payment mode is notify
     if (!$dao->find(TRUE)) {
         $dao->save();
     }
     CRM_Utils_Hook::post($hook, 'MembershipPayment', $dao->id, $dao);
     // CRM-14197 we are in the process on phasing out membershipPayment in favour of storing both contribution_id & entity_id (membership_id) on the line items
     // table. However, at this stage we have both - there is still quite a bit of refactoring to do to set the line_iten entity_id right the first time
     // however, we can assume at this stage that any contribution id will have only one line item with that membership type in the line item table
     // OR the caller will have taken responsibility for updating the line items themselves so we will update using SQL here
     if (!isset($params['membership_type_id'])) {
         $membership_type_id = civicrm_api3('membership', 'getvalue', array('id' => $dao->membership_id, 'return' => 'membership_type_id'));
     } else {
         $membership_type_id = $params['membership_type_id'];
     }
     $sql = "UPDATE civicrm_line_item li\n      LEFT JOIN civicrm_price_field_value pv ON pv.id = li.price_field_value_id\n      SET entity_table = 'civicrm_membership', entity_id = %1\n      WHERE pv.membership_type_id = %2\n      AND contribution_id = %3";
     CRM_Core_DAO::executeQuery($sql, array(1 => array($dao->membership_id, 'Integer'), 2 => array($membership_type_id, 'Integer'), 3 => array($dao->contribution_id, 'Integer')));
     return $dao;
 }
Esempio n. 12
0
 /**
  * @return array, Case record (api/v3 format)
  */
 public function getCase($case_id)
 {
     if ($this->case === NULL) {
         $resultCase = civicrm_api3('case', 'get', array('id' => $this->caseId));
     }
     return $resultCase;
 }
function civicrm_api3_mailchimp_synchronize($params)
{
    $return = $tags = $createdContact = array();
    $apiKey = CRM_Core_BAO_Setting::getItem('MailChimp Preferences', 'api_key', NULL, FALSE);
    $tagsCount = civicrm_api3('Tag', 'getcount', array('sequential' => 1));
    $tagsGet = civicrm_api3('Tag', 'get', array('sequential' => 1, 'rowCount' => $tagsCount));
    foreach ($tagsGet['values'] as $tagIds => $tagsValues) {
        $tags[$tagsValues['id']] = $tagsValues['name'];
    }
    $mcClient = new Mailchimp($apiKey);
    $mcLists = new Mailchimp_Lists($mcClient);
    $lists = $mcLists->getList();
    foreach ($lists['data'] as $listsDetails) {
        if (!in_array($listsDetails['name'], $tags)) {
            $tagsCreate = civicrm_api3('Tag', 'create', array('sequential' => 1, 'name' => $listsDetails['name']));
        }
        $tagsCount = civicrm_api3('Tag', 'getcount', array('sequential' => 1));
        $tagsGet = civicrm_api3('Tag', 'get', array('sequential' => 1, 'rowCount' => $tagsCount));
        foreach ($tagsGet['values'] as $tagIds => $tagsValues) {
            $tags[$tagsValues['id']] = $tagsValues['name'];
        }
        if (in_array($listsDetails['name'], $tags)) {
            $keyTags = array_search($listsDetails['name'], $tags);
            $members = $mcLists->members($listsDetails['id']);
            foreach ($members['data'] as $key => $value) {
                try {
                    $createdContact = civicrm_api3('Contact', 'create', array('sequential' => 1, 'contact_type' => "Individual", 'first_name' => $value['merges']['FNAME'], 'last_name' => $value['merges']['LNAME'], 'email' => $value['merges']['EMAIL'], 'api.EntityTag.create' => array('entity_id' => "\$value.id", 'entity_table' => "civicrm_contact", 'tag_id' => $keyTags), 'dupe_check' => true));
                } catch (CiviCRM_API3_Exception $e) {
                    $result = civicrm_api3('EntityTag', 'create', array('contact_id' => $e->getExtraParams()['ids'][0], 'tag_id' => $keyTags));
                }
            }
        }
    }
    return civicrm_api3_create_success();
}
Esempio n. 14
0
 /**
  * Method to implement hook civicrm_postProcess for Main Sector
  * @param $formName
  * @param $form
  */
 public static function postProcess($formName, &$form)
 {
     if ($formName == "CRM_Contactsegment_Form_ContactSegment") {
         $submitValues = $form->getVar('_submitValues');
         if (isset($submitValues['contact_segment_role']) && isset($submitValues['segment_child'])) {
             if ($submitValues['contact_segment_role'] == 'Expert' && empty($submitValues['segment_child'])) {
                 if (!isset($submitValues['is_main'])) {
                     $submitValues['is_main'] = 0;
                 }
                 $apiParams = array('contact_id' => $submitValues['contact_id'], 'role_value' => 'Expert', 'segment_id' => $submitValues['segment_parent'], 'is_main' => $submitValues['is_main']);
                 if ($submitValues['start_date']) {
                     $apiParams['start_date'] = $submitValues['start_date'];
                 }
                 if ($submitValues['end_date']) {
                     $apiParams['end_date'] = $submitValues['end_date'];
                 }
                 // if action is add, then retrieve the contact segment just created
                 $action = $form->getVar('_action');
                 if ($action == CRM_Core_Action::ADD) {
                     $existing = civicrm_api3('ContactSegment', 'Get', array('contact_id' => $submitValues['contact_id'], 'segment_id' => $submitValues['segment_parent'], 'role_value' => 'Expert'));
                     foreach ($existing['values'] as $existingContactSegment) {
                         $apiParams['id'] = $existingContactSegment['id'];
                     }
                 }
                 if (isset($submitValues['contact_segment_id']) && !empty($submitValues['contact_segment_id'])) {
                     $apiParams['id'] = $submitValues['contact_segment_id'];
                 }
                 civicrm_api3('ContactSegment', 'create', $apiParams);
             }
         }
     }
 }
Esempio n. 15
0
 /**
  * Create a new HRJobDetails based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobDetails|NULL
  *
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     $previousDetailsRevisionId = null;
     if ($hook == 'create') {
         $previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
         if (!empty($previousRevisionResult['values']['details_revision_id'])) {
             $previousDetailsRevisionId = $previousRevisionResult['values']['details_revision_id'];
         }
     }
     $instance = parent::create($params);
     // setting 'effective_date' if it's not set:
     $revision = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id'], 'id' => $instance->jobcontract_revision_id));
     if (!empty($revision['values'][0])) {
         $revisionData = array_shift($revision['values']);
         if (!$revisionData['effective_date']) {
             civicrm_api3('HRJobContractRevision', 'create', array('id' => $revisionData['id'], 'effective_date' => $instance->period_start_date));
         }
     }
     $revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
     $revision = CRM_Utils_Array::first($revisionResult['values']);
     $duplicate = CRM_Utils_Array::value('action', $params, $hook);
     if ($hook == 'create' && empty($revision['role_revision_id']) && $duplicate != 'duplicate' && empty($params['import'])) {
         //civicrm_api3('HRJobRole', 'create', array('jobcontract_id' => $revision['jobcontract_id'],'title' => $instance->title, 'location'=> $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
         CRM_Hrjobcontract_BAO_HRJobRole::create(array('jobcontract_id' => $revision['jobcontract_id'], 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
     }
     if ($previousDetailsRevisionId) {
         CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_details', $previousDetailsRevisionId, 'civicrm_hrjobcontract_details', $revision['details_revision_id']);
     }
     $contract = new CRM_Hrjobcontract_DAO_HRJobContract();
     $contract->id = $revision['jobcontract_id'];
     $contract->find(true);
     CRM_Hrjobcontract_JobContractDates::setDates($contract->contact_id, $revision['jobcontract_id'], $instance->period_start_date, $instance->period_end_date);
     return $instance;
 }
Esempio n. 16
0
 function run()
 {
     $countries = CRM_Bic_Parser_Parser::getParserList();
     $stats = civicrm_api3('Bic', 'stats');
     $total_count = 0;
     foreach ($countries as $country) {
         if (isset($stats['values'][$country])) {
             $total_count += $stats['values'][$country];
         } else {
             $stats['values'][$country] = 0;
         }
     }
     // gather the names
     $country_names = array();
     $config = CRM_Core_Config::singleton();
     $id2code = CRM_Core_PseudoConstant::countryIsoCode();
     $default_country = $id2code[$config->defaultContactCountry];
     $code2id = array_flip($id2code);
     $id2country = CRM_Core_PseudoConstant::country(FALSE, FALSE);
     foreach ($countries as $code) {
         $country_id = $code2id[$code];
         $country_name = $id2country[$country_id];
         $country_names[$code] = $country_name;
     }
     $this->assign('countries', $countries);
     $this->assign('country_names', $country_names);
     $this->assign('default_country', $default_country);
     $this->assign('stats', $stats['values']);
     $this->assign('total_count', $total_count);
     parent::run();
 }
 /**
  * create or update a Volunteer Commendation
  *
  * This function is invoked from within the web form layer
  *
  * @param array $params An assoc array of name/value pairs
  *  - aid: activity id of an existing commendation to update
  *  - cid: id of contact to be commended
  *  - vid: id of project for which contact is to be commended
  *  - details: text about the contact's exceptional volunteerism
  * @see self::requiredParamsArePresent for rules re required params
  * @return array Result of api.activity.create
  * @access public
  * @static
  */
 public static function create(array $params)
 {
     // check required params
     if (!self::requiredParamsArePresent($params)) {
         CRM_Core_Error::fatal('Not enough data to create commendation object.');
     }
     $activity_statuses = CRM_Activity_BAO_Activity::buildOptions('status_id', 'create');
     $api_params = array('activity_type_id' => self::getActivityTypeId(), 'status_id' => CRM_Utils_Array::key('Completed', $activity_statuses));
     $aid = CRM_Utils_Array::value('aid', $params);
     if ($aid) {
         $api_params['id'] = $aid;
     }
     $cid = CRM_Utils_Array::value('cid', $params);
     if ($cid) {
         $api_params['target_contact_id'] = $cid;
     }
     $vid = CRM_Utils_Array::value('vid', $params);
     if ($vid) {
         $project = CRM_Volunteer_BAO_Project::retrieveByID($vid);
         $api_params['subject'] = ts('Volunteer Commendation for %1', array('1' => $project->title, 'domain' => 'org.civicrm.volunteer'));
         $customFieldSpec = self::getCustomFields();
         $volunteer_project_id_field_name = $customFieldSpec['volunteer_project_id']['custom_n'];
         $api_params[$volunteer_project_id_field_name] = $vid;
     }
     if (array_key_exists('details', $params)) {
         $api_params['details'] = CRM_Utils_Array::value('details', $params);
     }
     return civicrm_api3('Activity', 'create', $api_params);
 }
 function postProcess()
 {
     $values = $this->exportValues();
     $branchOrPartnerID = $values['pcp_team_contact'];
     $params = array('version' => 3, 'entity_id' => $form->get('page_id'), "org_id" => $branchOrPartnerID);
     civicrm_api3('pcpteams', 'customcreate', $params);
 }
Esempio n. 19
0
 function run()
 {
     // Prepares variables for being sent to Smarty
     //Only show countries with attached information
     $countries = null;
     $stats = civicrm_api3('Bic', 'stats');
     foreach ($stats['values'] as $country => $count) {
         $countries[] = $country;
     }
     // Get country names
     $country_names = null;
     if ($countries) {
         $config = CRM_Core_Config::singleton();
         $country_names = array();
         $id2code = CRM_Core_PseudoConstant::countryIsoCode();
         $default_country = $id2code[$config->defaultContactCountry];
         $code2id = array_flip($id2code);
         $id2country = CRM_Core_PseudoConstant::country(false, false);
         foreach ($countries as $code) {
             $country_id = $code2id[$code];
             $country_name = $id2country[$country_id];
             $country_names[$code] = $country_name;
         }
     }
     // Sends variables to Smarty
     $this->assign('countries', $countries);
     $this->assign('country_names', $country_names);
     $this->assign('default_country', $default_country);
     $this->assign('show_message', true);
     parent::run();
 }
 /**
  * Load needed JS, CSS and settings for the backend Volunteer Management UI
  */
 public static function addResources($entity_id, $entity_table)
 {
     static $loaded = FALSE;
     $ccr = CRM_Core_Resources::singleton();
     if ($loaded || $ccr->isAjaxMode()) {
         return;
     }
     $loaded = TRUE;
     $config = CRM_Core_Config::singleton();
     // Vendor libraries
     $ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE);
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header', FALSE);
     $ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE);
     // Our stylesheet
     $ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css');
     // Add all scripts for our js app
     $weight = 0;
     $baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/';
     // This glob pattern will recurse the js directory up to 4 levels deep
     foreach (glob($baseDir . 'js/backbone/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) {
         $fileName = substr($file, strlen($baseDir));
         $ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++);
     }
     // Add our template
     CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported());
     CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl'));
     // Fetch event so we can set the default start time for needs
     // FIXME: Not the greatest for supporting non-events
     $entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id));
     // Static variables
     $ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat), 'constants' => array('CRM_Core_Action' => array('NONE' => 0, 'ADD' => 1, 'UPDATE' => 2, 'VIEW' => 4, 'DELETE' => 8, 'BROWSE' => 16, 'ENABLE' => 32, 'DISABLE' => 64, 'EXPORT' => 128, 'BASIC' => 256, 'ADVANCED' => 512, 'PREVIEW' => 1024, 'FOLLOWUP' => 2048, 'MAP' => 4096, 'PROFILE' => 8192, 'COPY' => 16384, 'RENEW' => 32768, 'DETACH' => 65536, 'REVERT' => 131072, 'CLOSE' => 262144, 'REOPEN' => 524288, 'MAX_ACTION' => 1048575))));
     // Check for problems
     _volunteer_checkResourceUrl();
 }
Esempio n. 21
0
 /**
  * Get AngularJS modules and their dependencies
  *
  * @return array
  *   list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
  * @see CRM_Utils_Hook::angularModules
  */
 public function getAngularModules()
 {
     // load angular files only if valid permissions are granted to the user
     if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
         return array();
     }
     $result = array();
     $result['crmMailing'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailing.js', 'ang/crmMailing/*.js'), 'css' => array('ang/crmMailing.css'), 'partials' => array('ang/crmMailing'));
     $result['crmMailingAB'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailingAB.js', 'ang/crmMailingAB/*.js', 'ang/crmMailingAB/*/*.js'), 'css' => array('ang/crmMailingAB.css'), 'partials' => array('ang/crmMailingAB'));
     $result['crmD3'] = array('ext' => 'civicrm', 'js' => array('ang/crmD3.js', 'bower_components/d3/d3.min.js'));
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     // Get past mailings
     // CRM-16155 - Limit to a reasonable number
     $civiMails = civicrm_api3('Mailing', 'get', array('is_completed' => 1, 'mailing_type' => array('IN' => array('standalone', 'winner')), 'return' => array('id', 'name', 'scheduled_date'), 'sequential' => 1, 'options' => array('limit' => 500, 'sort' => 'is_archived asc, scheduled_date desc')));
     // Generic params
     $params = array('options' => array('limit' => 0), 'sequential' => 1);
     $groupNames = civicrm_api3('Group', 'get', $params + array('is_active' => 1, 'check_permissions' => TRUE, 'return' => array('title', 'visibility', 'group_type', 'is_hidden')));
     $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array('is_active' => 1, 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text')));
     $emailAdd = civicrm_api3('Email', 'get', array('sequential' => 1, 'return' => "email", 'contact_id' => $contactID));
     $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array('sequential' => 1, 'is_active' => 1, 'return' => array("id", "msg_title"), 'workflow_id' => array('IS NULL' => "")));
     $mailTokens = civicrm_api3('Mailing', 'gettokens', array('entity' => array('contact', 'mailing'), 'sequential' => 1));
     $fromAddress = civicrm_api3('OptionValue', 'get', $params + array('option_group_id' => "from_email_address", 'domain_id' => CRM_Core_Config::domainID()));
     CRM_Core_Resources::singleton()->addSetting(array('crmMailing' => array('civiMails' => $civiMails['values'], 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents), 'groupNames' => $groupNames['values'], 'headerfooterList' => $headerfooterList['values'], 'mesTemplate' => $mesTemplate['values'], 'emailAdd' => $emailAdd['values'], 'mailTokens' => $mailTokens['values'], 'contactid' => $contactID, 'requiredTokens' => CRM_Utils_Token::getRequiredTokens(), 'enableReplyTo' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo'), 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled())))->addPermissions(array('view all contacts', 'access CiviMail', 'create mailings', 'schedule mailings', 'approve mailings', 'delete in CiviMail', 'edit message templates'));
     return $result;
 }
Esempio n. 22
0
 function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $params = $this->exportValues();
     $result = civicrm_api3('OptionValue', 'create', array('value' => $params['hour_value'], 'id' => CRM_Utils_Array::key($params['hour_type_select'], $this->_id)));
     $session->pushUserContext(CRM_Utils_System::url('civicrm/hour/editoption', "&value={$params['hour_value']}"));
 }
 protected function __construct()
 {
     $case_status_id = civicrm_api3('OptionGroup', 'getvalue', array('return' => 'id', 'name' => 'case_status'));
     $this->preperation = civicrm_api3('OptionValue', 'getsingle', array('name' => 'Preparation', 'option_group_id' => $case_status_id));
     $this->execution = civicrm_api3('OptionValue', 'getsingle', array('name' => 'Execution', 'option_group_id' => $case_status_id));
     $this->debriefing = civicrm_api3('OptionValue', 'getsingle', array('name' => 'Debriefing', 'option_group_id' => $case_status_id));
 }
/**
 * Implementation of hook_civicrm_install
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function dotmailer_civicrm_install()
{
    // Create a sync job
    $params = array('sequential' => 1, 'name' => 'Send to Dotmailer', 'description' => 'Add contacts to Dotmailer address book.', 'run_frequency' => 'Daily', 'api_entity' => 'Dotmailer', 'api_action' => 'sync', 'is_active' => 0);
    $result = civicrm_api3('job', 'create', $params);
    _dotmailer_civix_civicrm_install();
}
Esempio n. 25
0
/**
 * Add/Update a PaymentProcessor.
 *
 * @param array $params
 *
 * @return array
 *   API result array
 */
function civicrm_api3_payment_processor_create($params)
{
    if (empty($params['id']) && empty($params['payment_instrument_id'])) {
        $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', array('id' => $params['payment_processor_type_id'], 'return' => 'payment_instrument_id'));
    }
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
Esempio n. 26
0
 /**
  * Add payment fields depending on payment processor. The payment processor can implement the following functions to override the built in fields.
  *
  *  - getPaymentFormFields()
  *  - getPaymentFormFieldsMetadata()
  *  (planned - getBillingDetailsFormFields(), getBillingDetailsFormFieldsMetadata()
  *
  *  Note that this code is written to accommodate the possibility CiviCRM will switch to implementing pay later as a manual processor in future
  *
  * @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main $form
  * @param array $processor
  *   Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.
  * @param bool $forceBillingFieldsForPayLater
  *   Display billing fields even for pay later.
  * @param bool $isBackOffice
  *   Is this a back office function? If so the option to suppress the cvn needs to be evaluated.
  */
 public static function setPaymentFieldsByProcessor(&$form, $processor, $forceBillingFieldsForPayLater = FALSE, $isBackOffice = FALSE)
 {
     $form->billingFieldSets = array();
     if ($processor != NULL) {
         // ie it is pay later
         $paymentFields = self::getPaymentFields($processor);
         $paymentTypeName = self::getPaymentTypeName($processor);
         $paymentTypeLabel = self::getPaymentTypeLabel($processor);
         //@todo if we switch to iterating through $form->billingFieldSets we won't need to assign these directly
         $form->assign('paymentTypeName', $paymentTypeName);
         $form->assign('paymentTypeLabel', $paymentTypeLabel);
         $form->billingFieldSets[$paymentTypeName]['fields'] = $form->_paymentFields = array_intersect_key(self::getPaymentFieldMetadata($processor), array_flip($paymentFields));
         if (in_array('cvv2', $paymentFields) && $isBackOffice) {
             if (!civicrm_api3('setting', 'getvalue', array('name' => 'cvv_backoffice_required', 'group' => 'Contribute Preferences'))) {
                 $form->billingFieldSets[$paymentTypeName]['fields'][array_search('cvv2', $paymentFields)]['required'] = 0;
             }
         }
         $form->billingPane = array($paymentTypeName => $paymentTypeLabel);
         $form->assign('paymentFields', $paymentFields);
     }
     // @todo - replace this section with one similar to above per discussion - probably use a manual processor shell class to stand in for that capability
     //return without adding billing fields if billing_mode = 4 (@todo - more the ability to set that to the payment processor)
     // or payment processor is NULL (pay later)
     if ($processor == NULL && !$forceBillingFieldsForPayLater || CRM_Utils_Array::value('billing_mode', $processor) == 4) {
         return;
     }
     //@todo setPaymentFields defines the billing fields - this should be moved to the processor class & renamed getBillingFields
     // potentially pay later would also be a payment processor
     //also set the billingFieldSet to hold all the details required to render the fieldset so we can iterate through the fieldset - making
     // it easier to re-order in hooks etc. The billingFieldSets param is used to determine whether to show the billing pane
     CRM_Core_Payment_Form::setBillingDetailsFields($form);
     $form->billingFieldSets['billing_name_address-group']['fields'] = array();
 }
 /**
  * Method is mandatory and checks if the condition is met
  *
  * @param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @return bool
  * @access public
  */
 public function isConditionValid(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $contactId = $triggerData->getContactId();
     $donorHasAny = FALSE;
     $recurringParams = array('contact_id' => $contactId, 'is_test' => 0);
     try {
         $foundRecurring = civicrm_api3('ContributionRecur', 'Get', $recurringParams);
         foreach ($foundRecurring['values'] as $recurring) {
             if (CRM_Civirules_Utils::endDateLaterThanToday($recurring['end_date']) == TRUE || !isset($recurring['end_date'])) {
                 $donorHasAny = TRUE;
             }
         }
         if ($donorHasAny) {
             if ($this->conditionParams['has_recurring']) {
                 $isConditionValid = TRUE;
             } else {
                 $isConditionValid = FALSE;
             }
         } else {
             if ($this->conditionParams['has_recurring']) {
                 $isConditionValid = FALSE;
             } else {
                 $isConditionValid = TRUE;
             }
         }
     } catch (CiviCRM_API3_Exception $ex) {
         if ($this->conditionParams['has_recurring']) {
             $isConditionValid = FALSE;
         } else {
             $isConditionValid = TRUE;
         }
     }
     return $isConditionValid;
 }
Esempio n. 28
0
 /**
  * CRM_Casereports_Import constructor.
  */
 function __construct()
 {
     $config = CRM_Casereports_Config::singleton();
     $this->_acceptActivityTypeId = $config->getMaAcceptActivityTypeId();
     $this->_rejectActivityTypeId = $config->getMaRejectActivityTypeId();
     $this->_briefingActivityTypeId = $config->getBriefingActivityTypeId();
     $customGroup = $config->getMaAcceptCustomGroup();
     $this->_acceptTableName = $customGroup['table_name'];
     foreach ($customGroup['custom_fields'] as $customFieldId => $customField) {
         if ($customField['name'] == 'Assessment_SC') {
             $this->_scColumn = $customField['column_name'];
         }
         if ($customField['name'] == 'Assessment_CC') {
             $this->_ccColumn = $customField['column_name'];
         }
     }
     $this->_assessRepActivityTypeId = $config->getAssessRepActivityTypeId();
     $this->_assessSCActivityTypeId = $config->getAssessSCActivityTypeId();
     $this->_assessCCActivityTypeId = $config->getAssessCCActivityTypeId();
     $this->_assessAnamonActivityTypeId = $config->getAssessAnamonActivityTypeId();
     $this->_assessRepCustomTable = $config->getAssessRepCustomTable();
     $this->_assessSCCustomTable = $config->getAssessSCCustomTable();
     $this->_assessCCCustomTable = $config->getAssessCCCustomTable();
     $this->_assessAnamonCustomTable = $config->getAssessAnamonCustomTable();
     $this->_assessRepCustomColumn = $config->getAssessRepCustomColumn();
     $this->_assessSCCustomColumn = $config->getAssessSCCustomColumn();
     $this->_assessCCCustomColumn = $config->getAssessCCCustomColumn();
     $this->_assessAnamonCustomColumn = $config->getAssessAnamonCustomColumn();
     $this->_anaRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Anamon', 'return' => 'id'));
     $this->_ccRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Country Coordinator is', 'return' => 'id'));
     $this->_scRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Sector Coordinator', 'return' => 'id'));
     $this->_poRelTypeId = civicrm_api3('RelationshipType', 'Getvalue', array('name_a_b' => 'Project Officer for', 'return' => 'id'));
 }
Esempio n. 29
0
/**
 * Generic api wrapper used for quicksearch and autocomplete.
 *
 * @param array $apiRequest
 *
 * @return mixed
 */
function civicrm_api3_generic_getList($apiRequest)
{
    $entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']);
    $request = $apiRequest['params'];
    $meta = civicrm_api3_generic_getfields(array('action' => 'get') + $apiRequest, FALSE);
    // Hey api, would you like to provide default values?
    $fnName = "_civicrm_api3_{$entity}_getlist_defaults";
    $defaults = function_exists($fnName) ? $fnName($request) : array();
    _civicrm_api3_generic_getList_defaults($entity, $request, $defaults, $meta['values']);
    // Hey api, would you like to format the search params?
    $fnName = "_civicrm_api3_{$entity}_getlist_params";
    $fnName = function_exists($fnName) ? $fnName : '_civicrm_api3_generic_getlist_params';
    $fnName($request);
    $request['params']['check_permissions'] = !empty($apiRequest['params']['check_permissions']);
    $result = civicrm_api3($entity, 'get', $request['params']);
    // Hey api, would you like to format the output?
    $fnName = "_civicrm_api3_{$entity}_getlist_output";
    $fnName = function_exists($fnName) ? $fnName : '_civicrm_api3_generic_getlist_output';
    $values = $fnName($result, $request, $entity, $meta['values']);
    _civicrm_api3_generic_getlist_postprocess($result, $request, $values);
    $output = array('page_num' => $request['page_num']);
    // Limit is set for searching but not fetching by id
    if (!empty($request['params']['options']['limit'])) {
        // If we have an extra result then this is not the last page
        $last = $request['params']['options']['limit'] - 1;
        $output['more_results'] = isset($values[$last]);
        unset($values[$last]);
    }
    return civicrm_api3_create_success($values, $request['params'], $entity, 'getlist', CRM_Core_DAO::$_nullObject, $output);
}
 function run()
 {
     $apiURL = "https://www.googleapis.com/oauth2/v3";
     CRM_Utils_System::setTitle(ts('GoogleCallback'));
     $redirect_uri = rawurldecode(CRM_Utils_System::url('civicrm/civisocial/googlepluscallback', NULL, TRUE));
     $client_secret = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'google_plus_secret'));
     $client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'google_plus_key'));
     // Facebook sends a code to thge
     if (array_key_exists('code', $_GET)) {
         $google_code = $_GET['code'];
     } else {
         if (array_key_exists('error', $_GET)) {
             die("GOOGLE FATAL: the request returned without the code. Please try loging in again.");
         }
     }
     // Getting Access Token
     $access_token = "";
     $access_token_response = $this->get_response($apiURL, "token", TRUE, array("client_id" => $client_id, "client_secret" => $client_secret, "code" => $google_code, "redirect_uri" => $redirect_uri, "grant_type" => "authorization_code"));
     if (array_key_exists("error", $access_token_response)) {
         die($access_token_response["error"]);
     } else {
         $access_token = $access_token_response["access_token"];
     }
     // Get the user data
     $user_data_response = $this->get_response($apiURL, "userinfo", FALSE, array("access_token" => $access_token, "alt" => "json"));
     $this->assign('status', $user_data_response);
     $this->assign('currentTime', $user_data_response);
     parent::run();
 }