$AppUI->redirect('m=public&a=access_denied');
        }
    }
}
$obj->user_username = strtolower($obj->user_username);
// !User's contact information not deleted - left for history.
if ($del) {
    $result = $obj->delete($AppUI);
    $message = $result ? 'User deleted' : $obj->getError();
    $path = $result ? 'm=admin' : 'm=public&a=access_denied';
    $status = $result ? UI_MSG_ALERT : UI_MSG_ERROR;
    $AppUI->setMsg($message, $status);
    $AppUI->redirect($path);
}
$contact->contact_owner = $contact->contact_owner ? $contact->contact_owner : $AppUI->user_id;
$contactArray = $contact->getContactMethods();
$result = $contact->store($AppUI);
if ($result) {
    $contact->setContactMethods($contactArray);
    $obj->user_contact = $contact->contact_id;
    if ($obj->store($AppUI)) {
        if ($isNewUser && w2PgetParam($_POST, 'send_user_mail', 0)) {
            notifyNewUserCredentials($contact->contact_email, $contact->contact_first_name, $obj->user_username, $_POST['user_password']);
        }
        if (isset($_REQUEST['user_role']) && $_REQUEST['user_role']) {
            $perms =& $AppUI->acl();
            if ($perms->insertUserRole($_REQUEST['user_role'], $obj->user_id)) {
                $AppUI->setMsg('', UI_MSG_ALERT, true);
            } else {
                $AppUI->setMsg('failed to add role', UI_MSG_ERROR);
            }
Exemple #2
0
}
$department = $AppUI->getState('UsrProjIdxDepartment') !== null ? $AppUI->getState('UsrProjIdxDepartment') : $company_prefix . $AppUI->user_company;
//if $department contains the $company_prefix string that it's requesting a company and not a department.  So, clear the
// $department variable, and populate the $company_id variable.
if (!(strpos($department, $company_prefix) === false)) {
    $company_id = substr($department, strlen($company_prefix));
    $AppUI->setState('UsrProjIdxCompany', $company_id);
    unset($department);
}
$tab = $AppUI->processIntState('UserVwTab', $_GET, 'tab', 0);
// pull data
$user = new CUser();
$user->loadFull($user_id);
$contact = new CContact();
$contact->contact_id = $user->user_contact;
$methods = $contact->getContactMethods();
$methodLabels = w2PgetSysVal('ContactMethods');
if (!$user) {
    $titleBlock = new CTitleBlock('Invalid User ID', 'helix-setup-user.png', $m, "{$m}.{$a}");
    $titleBlock->addCrumb('?m=admin', 'users list');
    $titleBlock->show();
} else {
    $countries = w2PgetSysVal('GlobalCountries');
    // setup the title block
    $titleBlock = new CTitleBlock('View User', 'helix-setup-user.png', $m, "{$m}.{$a}");
    if ($canRead) {
        $titleBlock->addCrumb('?m=admin', 'users list');
    }
    if ($canEdit || $user_id == $AppUI->user_id) {
        $titleBlock->addCrumb('?m=admin&a=addedituser&user_id=' . $user_id, 'edit this user');
        $titleBlock->addCrumb('?m=contacts&a=addedit&contact_id=' . $user->contact_id, 'edit this contact');
 /**
  * Get Request Handler
  *
  * This method is called when a request is a GET
  *
  * @return array
  */
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $contact_id = $this->getParam('contact_id', self::TYPE_INT);
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $contact = new CContact();
     $allowed_contacts = $contact->getAllowedRecords($AppUI->user_id);
     // Contact ID is the key, so lets get them in an array so we can
     // easily check
     $allowed_contacts = array_keys($allowed_contacts);
     if (!in_array($contact_id, $allowed_contacts)) {
         throw new Frapi_Error('PERMISSION_ERROR');
     }
     // User has permission so load the contact for display
     $contact_array = (array) $contact->load($contact_id);
     $contact_array['contact_methods'] = $contact->getContactMethods();
     // Remove the data that is not for display
     unset($contact_array['_tbl_prefix'], $contact_array['_tbl'], $contact_array['_tbl_key'], $contact_array['_error'], $contact_array['_query'], $contact_array['_tbl_module']);
     $this->data['contact'] = $contact_array;
     $this->data['success'] = true;
     return $this->toArray();
 }
Exemple #4
0
// Fields 76 - 80
$text .= sprintf("%s", "\"Notes\",\"Office Location\",\"Organizational ID Number\",\"PO Box\",\"Priority\",");
// Fields 81 - 85
$text .= sprintf("%s", "\"Private\",\"Profession\",\"Referred By\",\"Sensitivity\",\"Spouse\",");
// Fields 86 - 90
$text .= sprintf("%s", "\"User 1\",\"User 2\",\"User 3\",\"User 4\",\"Web Page\",");
$custom_fields = w2p_Core_CustomFields::getCustomFieldList('contacts');
foreach ($custom_fields as $f) {
    $text .= sprintf("%s", "\"{$f['field_description']}\",");
}
$text .= sprintf("%s\r\n", "");
$contactList = CContact::searchContacts();
foreach ($contactList as $contact) {
    $myContact = new CContact();
    $myContact->contact_id = $contact['contact_id'];
    $contactMethods = $myContact->getContactMethods();
    // Fields 1- 10
    $text .= sprintf("\"\",\"%s\",\"\",\"%s\",\"\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",", $contact['contact_first_name'], $contact['contact_last_name'], $contact['company_name'], $contact['dept_name'], $contact['contact_title'], $contact['contact_address1'], $contact['contact_address2']);
    // Fields 11- 20
    $text .= sprintf(",\"%s\",\"%s\",\"%s\",,,,,,,", $contact['contact_city'], $contact['contact_state'], $contact['contact_zip']);
    // Fields 21- 30
    $text .= sprintf(",,,,,,,,,,");
    // Fields 31- 40
    $text .= sprintf(",\"%s\",,,,,,,,,", $contact['contact_phone']);
    // Fields 41- 50
    settype($contactMethods['phone_mobile'], 'string');
    $text .= sprintf("\"%s\",,,,,,,,\"\",\"0/0/00\",", '' . $contactMethods['phone_mobile']);
    // Fields 51- 60
    if ($contact['contact_type'] != '') {
        $categories = "web2Project; " . $contact['contact_type'];
    } else {
 public function testGetContactMethods()
 {
     $methods = array('phone_mobile' => '202-555-1212', 'url' => 'http://web2project.net', 'email_alt' => '*****@*****.**', 'im_skype' => 'example_s', 'im_google' => 'example_g');
     $contact = new CContact();
     $contact->contact_id = 1;
     $contact->setContactMethods($methods);
     $results = $contact->getContactMethods(array('phone_mobile', 'im_skype'));
     $this->AssertEquals(2, count($results));
     $this->assertEquals($methods['phone_mobile'], $results['phone_mobile']);
     $this->assertEquals($methods['im_skype'], $results['im_skype']);
 }