コード例 #1
0
 /**
  * Tests the proper creation of a user & contact
  */
 public function testStoreCreate()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store();
     $contact = new CContact();
     $contact->overrideDatabase($this->mockDB);
     $contact->bind($this->post_data);
     $result = $contact->store();
     $this->assertTrue($result);
     $this->assertNotEquals(0, $contact->contact_id);
     $this->obj->user_contact = $contact->contact_id;
     $result = $this->obj->store();
     $this->assertTrue($result);
     $this->assertNotEquals(0, $this->obj->user_id);
 }
コード例 #2
0
<?php

/* CONTACTS $Id: do_contact_aed.php 5872 2009-04-25 00:09:56Z merlinyoda $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$obj = new CContact();
$msg = '';
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$del = dPgetParam($_POST, 'del', 0);
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Contact');
if ($del) {
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg("deleted", UI_MSG_ALERT, true);
        $AppUI->redirect("m=contacts");
    }
} else {
    $isNotNew = @$_POST['contact_id'];
    if ($msg = $obj->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true);
    }
    $AppUI->redirect();
コード例 #3
0
<?php

/* ADMIN $Id: do_user_aed.php,v 1.13 2005/03/11 00:46:46 gregorerhardt Exp $ */
include $AppUI->getModuleClass('contacts');
$del = isset($_REQUEST['del']) ? $_REQUEST['del'] : FALSE;
$obj = new CUser();
$contact = new CContact();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
if (!$contact->bind($_POST)) {
    $AppUI->setMsg($contact->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('User');
// !User's contact information not deleted - left for history.
if ($del) {
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg("deleted", UI_MSG_ALERT, true);
        $AppUI->redirect('', -1);
    }
    return;
}
$isNewUser = !$_REQUEST['user_id'];
if ($isNewUser) {
    // check if a user with the param Username already exists
コード例 #4
0
ファイル: vcardimport.php プロジェクト: n2i/xvnkb
         $contactValues["contact_email"] = $ci['EMAIL'][0]['value'][0][0];
         $contactValues["contact_email2"] = $ci['EMAIL'][1]['value'][0][0];
         $contactValues["contact_phone"] = $ci['TEL'][0]['value'][0][0];
         $contactValues["contact_phone2"] = $ci['TEL'][1]['value'][0][0];
         $contactValues["contact_mobile"] = $ci['TEL'][2]['value'][0][0];
         $contactValues["contact_address1"] = $ci['ADR'][0]['value'][2][0];
         $contactValues["contact_address2"] = $ci['ADR'][0]['value'][1][0] . ', ' . $ci['ORG'][0]['value'][0][0];
         $contactValues["contact_city"] = $ci['ADR'][0]['value'][3][0];
         $contactValues["contact_state"] = $ci['ADR'][0]['value'][4][0];
         $contactValues["contact_zip"] = $ci['ADR'][0]['value'][5][0];
         $contactValues["contact_country"] = $ci['ADR'][0]['value'][6][0];
         $contactValues["contact_notes"] = $ci['NOTE'][0]['value'][0][0];
         $contactValues["contact_order_by"] = $contactValues["contact_last_name"] . ', ' . $contactValues["contact_first_name"];
         $contactValues["contact_id"] = 0;
         // bind array to object
         if (!$obj->bind($contactValues)) {
             $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
             $AppUI->redirect();
         }
         // store vCard data for this object
         if ($msg = $obj->store()) {
             $AppUI->setMsg($msg, UI_MSG_ERROR);
         }
     }
     // one or more vCard imports were successful
     $AppUI->setMsg('vCard(s) imported', UI_MSG_OK, true);
     $AppUI->redirect();
 } else {
     // redirect in case of file upload trouble
     $AppUI->setMsg("vCardFileUploadError", UI_MSG_ERROR);
     $AppUI->redirect();
コード例 #5
0
    echo $AppUI->_('Name');
    ?>
</th>
	<th><?php 
    echo $AppUI->_('e-mail');
    ?>
</th>
	<th><?php 
    echo $AppUI->_('Department');
    ?>
</th>
</tr>
<?php 
    foreach ($rows as $row) {
        $contact = new CContact();
        $contact->bind($row);
        $dept_detail = $contact->getDepartmentDetails();
        $s .= '<tr><td>';
        $s .= '<a href="?m=contacts&amp;a=view&amp;contact_id=' . dPformSafe($row['contact_id']) . '">' . htmlspecialchars($row['contact_last_name'] . ', ' . $row['contact_first_name']) . '</a>';
        $s .= '<td><a href="mailto:' . dPformSafe($row['contact_email'], DP_FORM_URI) . '">' . htmlspecialchars($row['contact_email']) . '</a></td>';
        $s .= '<td>' . htmlspecialchars($dept_detail['dept_name']) . '</td>';
        $s .= '</tr>';
    }
}
$s .= '<tr><td colspan="3" align="right" valign="top" style="background-color:#ffffff">';
$s .= '<input type="button" class=button value="' . $AppUI->_('new contact') . '" onclick="javascript:window.location=\'./index.php?m=contacts&amp;a=addedit&amp;company_id=' . dPformSafe($company_id) . '&amp;company_name=' . dPformSafe($obj->company_name) . '\'">';
$s .= '</td></tr>';
echo $s;
?>
</table>
コード例 #6
0
 /**
  * Put Request Handler
  *
  * This method is called when a request is a PUT
  *
  * @return array
  */
 public function executePut()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     // 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');
     }
     $post_data = array('contact_id' => 0, 'contact_first_name' => $this->getParam('contact_first_name'), 'contact_last_name' => $this->getParam('contact_last_name'), 'contact_order_by' => $this->getParam('contact_order_by'), 'contact_private' => $this->getParam('contact_private'), 'contact_job' => $this->getParam('contact_job'), 'contact_company_name' => $this->getParam('contact_company_name'), 'contact_company' => $this->getParam('contact_company'), 'contact_department_name' => $this->getParam('contact_department_name'), 'contact_department' => $this->getParam('contact_department'), 'contact_title' => $this->getParam('contact_title'), 'contact_type' => $this->getParam('contact_type'), 'contact_address1' => $this->getParam('contact_address1'), 'contact_address2' => $this->getParam('contact_address2'), 'contact_city' => $this->getParam('contact_city'), 'contact_state' => $this->getParam('contact_state'), 'contact_zip' => $this->getParam('contact_zip'), 'contact_country' => $this->getParam('contact_country'), 'contact_birthday' => $this->getParam('contact_birthday'), 'contact_notes' => $this->getParam('contact_notes'));
     // Ugh, the store method uses $_POST directly for contact methods :(
     $_POST['contact_methods'] = $this->getParam('contact_methods');
     $contact = new CContact();
     $contact->bind($post_data);
     $error_array = $contact->store($AppUI);
     if ($error_array !== true) {
         $error_message = '';
         foreach ($error_array as $error) {
             $error_message .= $error . '. ';
         }
         throw new Frapi_Error('SAVE_ERROR', $error_message);
     }
     /*
      * TODO: How do we handle extra fields?
      */
     $contact = (array) $contact;
     // Remove the data that is not for display
     unset($contact['tbl_prefix'], $contact['_tbl'], $contact['_tbl_key'], $contact['_error'], $contact['_query']);
     $this->data['contact'] = $contact;
     $this->data['success'] = true;
     return new Frapi_Response(array('code' => 201, 'data' => $this->data));
 }
コード例 #7
0
ファイル: contacts.test.php プロジェクト: eureka2/web2project
 public function testCanDelete()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store($AppUI);
     $cantDelete = $this->obj->canDelete('error', true);
     $this->assertFalse($cantDelete);
     $contact = new CContact();
     $contact->bind($this->post_data);
     $contact->contact_first_name = 'Firstname3';
     $contact->contact_last_name = 'Lastname3';
     $contact->contact_display_name = '';
     $result = $contact->store($AppUI);
     $canDeleteUser = $contact->canDelete('error');
     $this->assertTrue($canDeleteUser);
 }