Example #1
0
 /**
  * @param int $iUserId
  * @param string $sTempFileName
  * @param int $iParsedCount
  * @return int
  */
 public function Import($iUserId, $sTempFileName, &$iParsedCount)
 {
     $iCount = -1;
     $iParsedCount = 0;
     if (file_exists($sTempFileName)) {
         $aCsv = api_Utils::CsvToArray($sTempFileName);
         if (is_array($aCsv)) {
             $iCount = 0;
             foreach ($aCsv as $aCsvItem) {
                 set_time_limit(30);
                 $this->oParser->Reset();
                 $oContact = new CContact();
                 $oContact->IdUser = $iUserId;
                 $this->oParser->SetContainer($aCsvItem);
                 $aParameters = $this->oParser->GetParameters();
                 foreach ($aParameters as $sPropertyName => $mValue) {
                     if ($oContact->IsProperty($sPropertyName)) {
                         $oContact->{$sPropertyName} = $mValue;
                     }
                 }
                 if (0 === strlen($oContact->FullName)) {
                     $oContact->FullName = trim($oContact->FirstName . ' ' . $oContact->LastName);
                 }
                 $iParsedCount++;
                 $oContact->__SKIP_VALIDATE__ = true;
                 if ($this->oApiContactsManager->CreateContact($oContact)) {
                     $iCount++;
                 }
                 unset($oContact, $aParameters, $aCsvItem);
             }
         }
     }
     return $iCount;
 }
Example #2
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);
 }
 public function addField($fieldName, $fieldValue)
 {
     if ('' == $fieldValue) {
         return '-';
     }
     $pieces = explode('_', $fieldName);
     $suffix = end($pieces);
     switch ($suffix) {
         case 'datetime':
             $myDate = intval($fieldValue) ? new w2p_Utilities_Date($this->AppUI->formatTZAwareTime($fieldValue, '%Y-%m-%d %T')) : null;
             $output = $myDate ? $myDate->format($this->dtf) : '-';
             break;
         case 'email':
             $output = w2p_email($fieldValue);
             break;
         case 'url':
             $value = str_replace(array('"', '"', '<', '>'), '', $fieldValue);
             $output = w2p_url($value);
             break;
         case 'owner':
             if (!$fieldValue) {
                 return '-';
             }
             $obj = new CContact();
             $obj->findContactByUserid($fieldValue);
             $link = '?m=users&a=view&user_id=' . $fieldValue;
             $output = '<a href="' . $link . '">' . $obj->contact_display_name . '</a>';
             break;
         case 'percent':
             $output = round($fieldValue) . '%';
             break;
         case 'description':
             $output = w2p_textarea($fieldValue);
             break;
         case 'company':
         case 'department':
         case 'project':
             $class = 'C' . ucfirst($suffix);
             $obj = new $class();
             $obj->load($fieldValue);
             $link = '?m=' . w2p_pluralize($suffix) . '&a=view&' . $suffix . '_id=' . $fieldValue;
             $output = '<a href="' . $link . '">' . $obj->{"{$suffix}" . '_name'} . '</a>';
             break;
         default:
             $output = htmlspecialchars($fieldValue, ENT_QUOTES);
     }
     return $output;
 }
Example #4
0
 /**
  * @param int $iUserId
  * @param string $sTempFileName
  * @param int $iParsedCount
  * @param int $iGroupId
  * @param bool $bIsShared
  * @return int
  */
 public function Import($iUserId, $sTempFileName, &$iParsedCount, $iGroupId, $bIsShared)
 {
     $iCount = -1;
     $iParsedCount = 0;
     if (file_exists($sTempFileName)) {
         $aCsv = api_Utils::CsvToArray($sTempFileName);
         if (is_array($aCsv)) {
             $oApiUsersManager = CApi::Manager('users');
             $oAccount = $oApiUsersManager->GetDefaultAccount($iUserId);
             $iCount = 0;
             foreach ($aCsv as $aCsvItem) {
                 set_time_limit(30);
                 $this->oParser->Reset();
                 $oContact = new CContact();
                 $oContact->IdUser = $iUserId;
                 $this->oParser->SetContainer($aCsvItem);
                 $aParameters = $this->oParser->GetParameters();
                 foreach ($aParameters as $sPropertyName => $mValue) {
                     if ($oContact->IsProperty($sPropertyName)) {
                         $oContact->{$sPropertyName} = $mValue;
                     }
                 }
                 if (0 === strlen($oContact->FullName)) {
                     $oContact->FullName = trim($oContact->FirstName . ' ' . $oContact->LastName);
                 }
                 if (0 !== strlen($oContact->HomeEmail)) {
                     $oContact->PrimaryEmail = \EPrimaryEmailType::Home;
                     $oContact->ViewEmail = $oContact->HomeEmail;
                 } else {
                     if (0 !== strlen($oContact->BusinessEmail)) {
                         $oContact->PrimaryEmail = \EPrimaryEmailType::Business;
                         $oContact->ViewEmail = $oContact->BusinessEmail;
                     } else {
                         if (0 !== strlen($oContact->OtherEmail)) {
                             $oContact->PrimaryEmail = \EPrimaryEmailType::Other;
                             $oContact->ViewEmail = $oContact->OtherEmail;
                         }
                     }
                 }
                 if (strlen($oContact->BirthdayYear) === 2) {
                     $oDt = DateTime::createFromFormat('y', $oContact->BirthdayYear);
                     $oContact->BirthdayYear = $oDt->format('Y');
                 }
                 $iParsedCount++;
                 $oContact->__SKIP_VALIDATE__ = true;
                 if ($oAccount) {
                     $oContact->IdDomain = $oAccount->IdDomain;
                     $oContact->IdTenant = $oAccount->IdTenant;
                 }
                 $oContact->SharedToAll = $bIsShared;
                 $oContact->GroupsIds = array($iGroupId);
                 if ($this->oApiContactsManager->CreateContact($oContact)) {
                     $iCount++;
                 }
                 unset($oContact, $aParameters, $aCsvItem);
             }
         }
     }
     return $iCount;
 }
 /**
  * @param string $sWhere
  * @param bool $bIgnoreHideInGab = false
  * @param int $iSharedTenantId = null
  * @return string
  */
 protected function getContactByWhere($sWhere, $bIgnoreHideInGab = false, $iSharedTenantId = null)
 {
     $aMap = api_AContainer::DbReadKeys(CContact::GetStaticMap());
     $aMap = array_map(array($this, 'escapeColumn'), $aMap);
     $sShared = is_int($iSharedTenantId) ? 'AND shared_to_all = 1' : 'AND shared_to_all = 0';
     $sHideInGab = $bIgnoreHideInGab ? '' : ' AND hide_in_gab = 0';
     $sSql = 'SELECT %s FROM %sawm_addr_book WHERE deleted = 0 AND auto_create = 0 ' . $sShared . $sHideInGab . ' AND %s';
     return sprintf($sSql, implode(', ', $aMap), $this->Prefix(), $sWhere);
 }
Example #6
0
 public function testLoad()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store();
     $this->assertTrue($result);
     $item = new CContact();
     $item->overrideDatabase($this->mockDB);
     $this->post_data['contact_id'] = $this->obj->contact_id;
     $this->mockDB->stageHash($this->post_data);
     $item->load($this->obj->contact_id);
     $this->assertEquals($this->obj->contact_first_name, $item->contact_first_name);
     $this->assertEquals($this->obj->contact_last_name, $item->contact_last_name);
     $this->assertEquals($this->obj->contact_display_name, $item->contact_display_name);
     $this->assertEquals($this->obj->contact_company, $item->contact_company);
     $this->assertEquals($this->obj->contact_department, $item->contact_department);
     $this->assertEquals($this->obj->contact_icon, $item->contact_icon);
     $this->assertEquals($this->obj->contact_owner, $item->contact_owner);
     $this->assertEquals($this->obj->contact_id, $item->contact_id);
 }
<?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
                $contact->contact_private = 1;
                $contact->store();
            }
        }
    } else {
        $AppUI->setMsg('failed to delete role', UI_MSG_ERROR);
    }
} else {
    if ($user_role) {
        $public_contact = false;
        if (dPgetConfig('user_contact_activate') && !$perms->checkLogin($user_id)) {
            $public_contact = true;
        }
        if ($perms->insertUserRole($user_role, $user_id)) {
            $AppUI->setMsg('added', UI_MSG_OK, true);
            if ($public_contact) {
                // Mark contact as public
                $obj = new CUser();
                $contact = new CContact();
                $obj->load($user_id);
                if ($contact->load($obj->user_contact)) {
                    $contact->contact_private = 0;
                    $contact->store();
                }
            }
        } else {
            $AppUI->setMsg('failed to add role', UI_MSG_ERROR);
        }
    }
}
$AppUI->redirect();
Example #9
0
    $AppUI->setState('UserIdxWhere', '');
} elseif (isset($_POST['search_string'])) {
    $AppUI->setState('UserIdxWhere', $_POST['search_string']);
    $AppUI->setState('UserIdxStub', '');
}
$stub = $AppUI->getState('UserIdxStub');
$where = $AppUI->getState('UserIdxWhere');
$where = w2PformSafe($where, true);
if (isset($_GET['orderby'])) {
    $AppUI->setState('UserIdxOrderby', w2PgetParam($_GET, 'orderby', null));
}
$orderby = $AppUI->getState('UserIdxOrderby') ? $AppUI->getState('UserIdxOrderby') : 'user_username';
$orderby = $tab == 3 || $orderby != 'date_time_in' && $orderby != 'user_ip' ? $orderby : 'user_username';
// Pull First Letters
$letters = CUser::getFirstLetters();
$letters = $letters . CContact::getFirstLetters($AppUI->user_id, true);
$a2z = '<a href="./index.php?m=users&stub=0">' . $AppUI->_('All') . '</a>&nbsp;&nbsp;&nbsp;&nbsp;';
for ($c = 65; $c < 91; $c++) {
    $cu = chr($c);
    $cell = !(mb_strpos($letters, $cu) === false) ? '<a href="?m=users&stub=' . $cu . '">' . $cu . '</a>' : '<font color="#999999">' . $cu . '</font>';
    $a2z .= $cell . '&nbsp;';
}
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock('User Management', 'icon.png', $m);
$titleBlock->addSearchCell($where);
$titleBlock->addCell($a2z);
$titleBlock->addButton('New user', '?m=users&a=addedit');
$titleBlock->show();
?>
<script language="javascript" type="text/javascript">
<?php 
Example #10
0
    }
} else {
    header('Location: newuser.php?msg=spam');
}
if (w2PgetConfig('activate_external_user_creation') != 'true') {
    die('You should not access this file directly');
}
$username = w2PgetParam($_POST, 'user_username', 0);
$username = preg_replace("/[^A-Za-z0-9]/", "", $username);
$user = new CAdmin_User();
$result = $user->loadAll(null, "user_username = '******'");
if (count($result)) {
    header('Location: newuser.php?msg=existing-user');
}
$email = w2PgetParam($_POST, 'contact_email', 0);
$contact = new CContact();
$result = $contact->loadAll(null, "contact_email = '{$email}'");
if (count($result)) {
    header('Location: newuser.php?msg=existing-email');
}
if (!$user->bind($_POST)) {
    $AppUI->setMsg($user->getError(), UI_MSG_ERROR);
    header('Location: newuser.php?msg=user');
}
if (!$contact->bind($_POST)) {
    $AppUI->setMsg($contact->getError(), UI_MSG_ERROR);
    header('Location: newuser.php?msg=contact');
}
$result = $contact->store();
if (count($contact->getError())) {
    header('Location: newuser.php?msg=contact');
Example #11
0
}
$del = isset($_REQUEST['del']) ? w2PgetParam($_REQUEST, 'del', false) : false;
$notify_new_user = isset($_POST['notify_new_user']) ? $_POST['notify_new_user'] : 0;
$perms =& $AppUI->acl();
if (!$perms->checkModule('admin', 'edit')) {
    $AppUI->redirect('m=public&a=access_denied');
}
if (!$perms->checkModule('users', 'edit')) {
    $AppUI->redirect('m=public&a=access_denied');
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Roles');
if ($_REQUEST['user_id']) {
    $user = new CUser();
    $user->load($_REQUEST['user_id']);
    $contact = new CContact();
    $contact->load($user->user_contact);
}
if ($del) {
    if ($perms->deleteUserRole(w2PgetParam($_REQUEST, 'role_id', 0), w2PgetParam($_REQUEST, 'user_id', 0))) {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg('failed to delete role', UI_MSG_ERROR);
        $AppUI->redirect();
    }
    return;
}
if (isset($_REQUEST['user_role']) && $_REQUEST['user_role']) {
    if ($perms->insertUserRole($_REQUEST['user_role'], $_REQUEST['user_id'])) {
        if ($notify_new_user) {
Example #12
0
<?php

/* CONTACTS $Id: view.php 6200 2013-01-15 06:24:08Z ajdonnison $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$contact_id = intval(dPgetParam($_GET, 'contact_id', 0));
$AppUI->savePlace();
// load the record data
$msg = '';
$row = new CContact();
$canDelete = $row->canDelete($msg, $contact_id);
// Don't allow to delete contacts, that have a user associated to them.
$q = new DBQuery();
$q->addTable('users');
$q->addQuery('user_id');
$q->addWhere('user_contact = ' . $contact_id);
$sql = $q->prepare();
$q->clear();
$tmp_user = db_loadResult($sql);
if (!empty($tmp_user)) {
    $canDelete = false;
}
$canEdit = getPermission($m, 'edit', $contact_id);
if (!$row->load($contact_id) && $contact_id > 0) {
    $AppUI->setMsg('Contact');
    $AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
    $AppUI->redirect();
} else {
    if ($row->contact_private && $row->contact_owner != $AppUI->user_id && $row->contact_owner && $contact_id != 0) {
        $AppUI->redirect('m=public&a=access_denied');
Example #13
0
// check permissions for this record
$canEdit = canEdit('system');
// Check permissions
if (!$canEdit && $user_id != $AppUI->user_id) {
    $AppUI->redirect('m=public&a=access_denied');
}
// load the preferences
$q = new w2p_Database_Query();
$q->addTable('user_preferences');
$q->addQuery('pref_name, pref_value');
$q->addWhere('pref_user = '******'Default';
}
$titleBlock = new w2p_Theme_TitleBlock('Edit User Preferences', 'myevo-weather.png', $m, $m . '.' . $a);
$perms =& $AppUI->acl();
if ($canEdit) {
    $titleBlock->addCrumb('?m=system', 'system admin');
    $titleBlock->addCrumb('?m=system&a=systemconfig', 'system configuration');
}
$titleBlock->show();
?>
<script language="javascript" type="text/javascript">
function submitIt() {
	var form = document.changeuser;
	// Collate the checked states of the task log stuff
Example #14
0
 function afterWriteContent($path, \Sabre\DAV\IFile $node)
 {
     if ($node instanceof \Sabre\CardDAV\ICard) {
         $iUserId = $this->server->getUser();
         if (isset($iUserId)) {
             $iTenantId = $node instanceof \Afterlogic\DAV\CardDAV\SharedCard ? 0 : null;
             $sContactFileName = $node->getName();
             $oContactDb = $this->oApiContactsManager->getContactByStrId($iUserId, $sContactFileName, $iTenantId);
             if (!isset($oContactDb)) {
                 $oVCard = \Sabre\VObject\Reader::read($node->get(), \Sabre\VObject\Reader::OPTION_IGNORE_INVALID_LINES);
                 if ($oVCard && $oVCard->UID) {
                     $oContactDb = $this->oApiContactsManager->getContactByStrId($iUserId, (string) $oVCard->UID . '.vcf', $iTenantId);
                 }
             }
             $oContact = new \CContact();
             $oContact->InitFromVCardStr($iUserId, $node->get());
             $oContact->IdContactStr = $sContactFileName;
             $oContact->IdTenant = $iTenantId;
             if (isset($oContactDb)) {
                 $oContact->IdContact = $oContactDb->IdContact;
                 $oContact->IdDomain = $oContactDb->IdDomain;
                 $oContact->SharedToAll = !!$oContactDb->SharedToAll;
                 $this->oApiContactsManager->updateContact($oContact);
             } else {
                 $this->oApiContactsManager->createContact($oContact);
             }
         }
     }
 }
Example #15
0
echo $AppUI->_($message_id ? 'Edit Message' : 'Add Message');
?>
</strong></th>
        </tr>
        <?php 
if ($message_parent >= 0) {
    //check if this is a reply-post; if so, printout the original message
    $date = intval($message->message_date) ? new w2p_Utilities_Date($message->message_date) : new w2p_Utilities_Date();
    ?>
            <tr>
                <td align="right"><?php 
    echo $AppUI->_('Author');
    ?>
:</td>
                <td align="left"><?php 
    echo CContact::getContactByUserid($message->message_author);
    ?>
 (<?php 
    echo $AppUI->formatTZAwareTime($message->message_date, $df . ' ' . $tf);
    ?>
)</td>
            </tr>
            <tr><td align="right"><?php 
    echo $AppUI->_('Subject');
    ?>
:</td><td align="left"><?php 
    echo $message->message_title;
    ?>
</td></tr>
            <tr><td align="right" valign="top"><?php 
    echo $AppUI->_('Message');
Example #16
0
</strong>
            </th>
        </tr>
        <?php 
if ($message_parent >= 0) {
    //check if this is a reply-post; if so, printout the original message
    $messageAuthor = isset($message->message_author) ? $message->message_author : $AppUI->user_id;
    $date = intval($message->message_date) ? new w2p_Utilities_Date($message->message_date) : new w2p_Utilities_Date();
    ?>
            <tr>
                <td align="right"><?php 
    $form->showLabel('Author');
    ?>
</td>
                <td align="left"><?php 
    echo CContact::getContactByUserid($messageAuthor);
    ?>
 (<?php 
    echo $AppUI->formatTZAwareTime($message->message_date, $df . ' ' . $tf);
    ?>
)</td>
            </tr>
            <tr><td align="right"><?php 
    $form->showLabel('Subject');
    ?>
</td>
                <td align="left"><?php 
    echo $message->message_title;
    ?>
</td></tr>
            <tr><td align="right" valign="top"><?php 
Example #17
0
 /**
  * @param int $iUserId
  * @param mixed $mContactId
  * @return CContact | false
  */
 public function getContactById($iUserId, $mContactId)
 {
     $oContact = false;
     if ($this->init($iUserId)) {
         $oContactItem = $this->getItem($iUserId, \afterlogic\DAV\Constants::ADDRESSBOOK_DEFAULT_NAME, $mContactId);
         if ($oContactItem) {
             $sVCardData = $oContactItem['data'];
             if ($sVCardData) {
                 $oContact = new CContact();
                 $oContact->InitFromVCardStr($iUserId, $sVCardData);
                 $oContact->IdContact = $mContactId;
                 $oContact->ETag = $oContactItem['etag'];
             }
         }
     }
     return $oContact;
 }
Example #18
0
 public function createsqluser($username, $password, $ldap_attribs = array())
 {
     global $AppUI;
     $hash_pass = MD5($password);
     if (!count($ldap_attribs) == 0) {
         // Contact information based on the inetOrgPerson class schema
         $c = new CContact();
         $c->contact_first_name = $ldap_attribs['givenname'][0];
         $c->contact_last_name = $ldap_attribs['sn'][0];
         $c->contact_city = $ldap_attribs['l'][0];
         $c->contact_country = $ldap_attribs['country'][0];
         $c->contact_state = $ldap_attribs['st'][0];
         $c->contact_zip = $ldap_attribs['postalcode'][0];
         $c->contact_job = $ldap_attribs['title'][0];
         $c->contact_email = $ldap_attribs['mail'][0];
         $c->contact_phone = $ldap_attribs['telephonenumber'][0];
         $c->contact_owner = $AppUI->user_id;
         $c->store();
         $contactArray = array('phone_mobile' => $ldap_attribs['mobile'][0]);
         $c->setContactMethods($contactArray);
     }
     $contact_id = $c->contact_id == null ? 'NULL' : $c->contact_id;
     $u = new CUser();
     $u->user_username = $username;
     $u->user_password = $hash_pass;
     $u->user_type = 0;
     // Changed from 1 (administrator) to 0 (Default user)
     $u->user_contact = (int) $contact_id;
     $u->store();
     $user_id = $u->user_id;
     $this->user_id = $user_id;
     $acl =& $AppUI->acl();
     $acl->insertUserRole($acl->get_group_id('anon'), $this->user_id);
 }
Example #19
0
// check whether vCard file should be fetched from source or parsed for vCardKeys; criteria: get parameters
if (isset($_FILES['vcf']) && isset($_GET['suppressHeaders']) && $_GET['suppressHeaders'] == 'true') {
    //parse and store vCard file
    $vcf = $_FILES['vcf'];
    // include PEAR vCard class
    require_once $AppUI->getLibraryClass('PEAR/Contact_Vcard_Parse');
    if (is_uploaded_file($vcf['tmp_name'])) {
        // instantiate a parser object
        $parse = new Contact_Vcard_Parse();
        // parse a vCard file and store the data
        // in $cardinfo
        $cardinfo = $parse->fromFile($vcf['tmp_name']);
        // store the card info array
        foreach ($cardinfo as $ci) {
            //one file can contain multiple vCards
            $obj = new CContact();
            //transform the card info array to dP store format
            $contactValues["contact_last_name"] = $ci['N'][0]['value'][0][0];
            $contactValues["contact_first_name"] = $ci['N'][0]['value'][1][0];
            $contactValues["contact_title"] = $ci['N'][0]['value'][3][0];
            $contactValues["contact_birthday"] = $ci['BDAY'][0]['value'][0][0];
            $contactValues["contact_company"] = $ci['UID'][0]['value'][0][0];
            $contactValues["contact_type"] = $ci['N'][0]['value'][2][0];
            $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];
Example #20
0
<?php

/* $Id: do_user_aed.php 1866 2011-05-01 06:20:10Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/admin/do_user_aed.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) w2PgetParam($_POST, 'del', 0);
$obj = new CUser();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$contact = new CContact();
if (!$contact->bind($_POST)) {
    $AppUI->setMsg($contact->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
$action = $del ? 'deleted' : 'stored';
$contact_id = (int) w2PgetParam($_POST, 'contact_id', 0);
$user_id = (int) w2PgetParam($_POST, 'user_id', 0);
$isNewUser = !$user_id;
$perms =& $AppUI->acl();
if ($del) {
} elseif ($isNewUser) {
    if (!canAdd('admin')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
    if (!canAdd('users')) {
        $AppUI->redirect('m=public&a=access_denied');
    }
} else {
<?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();
Example #22
0
<a href="?m=contacts&a=vcardexport&suppressHeaders=true&contact_id=<?php 
        echo $contactid;
        ?>
" style="float: right;"><?php 
        echo w2PtoolTip($m, 'exportar como vCard') . w2PshowImage('vcard.png') . w2PendTip();
        ?>
</a>
                                                    <a href="?m=contacts&a=addedit&contact_id=<?php 
        echo $contactid;
        ?>
" style="float: right;"><?php 
        echo w2PtoolTip($m, 'edit this contact') . w2PshowImage('icons/pencil.gif') . w2PendTip();
        ?>
</a>
													<?php 
        $projectList = CContact::getProjects($contactid);
        $df = $AppUI->getPref('SHDATEFORMAT');
        $df .= ' ' . $AppUI->getPref('TIMEFORMAT');
        $contact_updatekey = $carr[$z][$x]['contact_updatekey'];
        $contact_lastupdate = $carr[$z][$x]['contact_lastupdate'];
        $contact_updateasked = $carr[$z][$x]['contact_updateasked'];
        $last_ask = new w2p_Utilities_Date($contact_updateasked);
        $lastAskFormatted = $last_ask->format($df);
        if (count($projectList) > 0) {
            echo '<a href="" onclick="	window.open(\'./index.php?m=public&a=selector&dialog=1&callback=goProject&table=projects&user_id=' . $carr[$z][$x]['contact_id'] . '\', \'selector\', \'left=50,top=50,height=250,width=400,resizable\');return false;">' . w2PshowImage('projects.png', '', '', $m, 'click to view projects associated with this contact') . '</a>';
        }
        if ($contact_updateasked && (!$contact_lastupdate || $contact_lastupdate == 0) && $contact_updatekey) {
            echo w2PtoolTip('info', 'Waiting for Contact Update Information. (Asked on: ' . $lastAskFormatted . ')') . '<img src="' . w2PfindImage('log-info.gif') . '" style="float: right;">' . w2PendTip();
        } elseif ($contact_updateasked && (!$contact_lastupdate || $contact_lastupdate == 0) && !$contact_updatekey) {
            echo w2PtoolTip('info', 'Waiting for too long! (Asked on ' . $lastAskFormatted . ')') . '<img src="' . w2PfindImage('log-error.gif') . '" style="float: right;">' . w2PendTip();
        } elseif ($contact_updateasked && !$contact_updatekey) {
Example #23
0
<?php

/* CONTACTS $Id: view.php,v 1.14.4.8 2007/06/21 02:06:17 cyberhorse Exp $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$contact_id = intval(dPgetParam($_GET, 'contact_id', 0));
$AppUI->savePlace();
// check permissions for this record
//$canEdit = !getDenyEdit( $m, $contact_id );
//if (!$canEdit) {
//	$AppUI->redirect( "m=public&a=access_denied" );
//}
// load the record data
$msg = '';
$row = new CContact();
$canDelete = $row->canDelete($msg, $contact_id);
// Don't allow to delete contacts, that have a user associated to them.
$q = new DBQuery();
$q->addTable('users');
$q->addQuery('user_id');
$q->addWhere('user_contact = ' . $contact_id);
$sql = $q->prepare();
$q->clear();
$tmp_user = db_loadResult($sql);
if (!empty($tmp_user)) {
    $canDelete = false;
}
$canEdit = $perms->checkModuleItem($m, "edit", $contact_id);
if (!$row->load($contact_id) && $contact_id > 0) {
    $AppUI->setMsg('Contact');
Example #24
0
 /**
  * Downloads message from IMAP and returns it.
  * 
  * @param CAccount $oAccount Account object.
  * @param string $sFolderFullNameRaw Raw full name of the Folder.
  * @param int $iUid UID of the message to download.
  * @param string $sRfc822SubMimeIndex = ''. Index at which a message is taken to parse. Index is used if the message is another message attachment.
  * @param bool $bParseICalAndVcard = false. If **true** ical and vcard attachments will be parsed.
  * @param bool $bParseAsc = false. If **true** attachments with extension .asc will be parsed.
  * @param int $iBodyTextLimit = 0. If **> 0** will be received only part of the message body. If **= 0** the message body is not limited.
  *
  * @return CApiMailMessage
  *
  * @throws CApiInvalidArgumentException
  */
 public function getMessage($oAccount, $sFolderFullNameRaw, $iUid, $sRfc822SubMimeIndex = '', $bParseICalAndVcard = false, $bParseAsc = false, $iBodyTextLimit = 0)
 {
     if (0 === strlen($sFolderFullNameRaw) || !is_numeric($iUid) || 0 >= (int) $iUid) {
         throw new CApiInvalidArgumentException();
     }
     $iUid = (int) $iUid;
     $oImapClient =& $this->_getImapClient($oAccount);
     $oImapClient->FolderExamine($sFolderFullNameRaw);
     $oMessage = false;
     $sICalMimeIndex = '';
     $sVCardMimeIndex = '';
     $aTextMimeIndexes = array();
     $aAscPartsIds = array();
     $aFetchResponse = $oImapClient->Fetch(array(\MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE), $iUid, true);
     $oBodyStructure = 0 < count($aFetchResponse) ? $aFetchResponse[0]->GetFetchBodyStructure($sRfc822SubMimeIndex) : null;
     if ($oBodyStructure) {
         $aTextParts = $oBodyStructure->SearchHtmlOrPlainParts();
         if (is_array($aTextParts) && 0 < count($aTextParts)) {
             foreach ($aTextParts as $oPart) {
                 $aTextMimeIndexes[] = array($oPart->PartID(), $oPart->Size());
             }
         }
         if ($bParseICalAndVcard) {
             $aICalPart = $oBodyStructure->SearchByContentType('text/calendar');
             $oICalPart = is_array($aICalPart) && 0 < count($aICalPart) ? $aICalPart[0] : null;
             $sICalMimeIndex = $oICalPart ? $oICalPart->PartID() : '';
             $aVCardPart = $oBodyStructure->SearchByContentType('text/vcard');
             $aVCardPart = $aVCardPart ? $aVCardPart : $oBodyStructure->SearchByContentType('text/x-vcard');
             $oVCardPart = is_array($aVCardPart) && 0 < count($aVCardPart) ? $aVCardPart[0] : null;
             $sVCardMimeIndex = $oVCardPart ? $oVCardPart->PartID() : '';
         }
         if ($bParseAsc) {
             $aAscParts = $oBodyStructure->SearchByCallback(function ($oPart) {
                 return '.asc' === \strtolower(\substr(\trim($oPart->FileName()), -4));
             });
             if (is_array($aAscParts) && 0 < count($aAscParts)) {
                 foreach ($aAscParts as $oPart) {
                     $aAscPartsIds[] = $oPart->PartID();
                 }
             }
         }
     }
     $aFetchItems = array(\MailSo\Imap\Enumerations\FetchType::INDEX, \MailSo\Imap\Enumerations\FetchType::UID, \MailSo\Imap\Enumerations\FetchType::RFC822_SIZE, \MailSo\Imap\Enumerations\FetchType::INTERNALDATE, \MailSo\Imap\Enumerations\FetchType::FLAGS, 0 < strlen($sRfc822SubMimeIndex) ? \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $sRfc822SubMimeIndex . '.HEADER]' : \MailSo\Imap\Enumerations\FetchType::BODY_HEADER_PEEK);
     if (0 < count($aTextMimeIndexes)) {
         if (0 < strlen($sRfc822SubMimeIndex) && is_numeric($sRfc822SubMimeIndex)) {
             $sLine = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $aTextMimeIndexes[0][0] . '.1]';
             if (\is_numeric($iBodyTextLimit) && 0 < $iBodyTextLimit && $iBodyTextLimit < $aTextMimeIndexes[0][1]) {
                 $sLine .= '<0.' . (int) $iBodyTextLimit . '>';
             }
             $aFetchItems[] = $sLine;
         } else {
             foreach ($aTextMimeIndexes as $aTextMimeIndex) {
                 $sLine = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $aTextMimeIndex[0] . ']';
                 if (\is_numeric($iBodyTextLimit) && 0 < $iBodyTextLimit && $iBodyTextLimit < $aTextMimeIndex[1]) {
                     $sLine .= '<0.' . (int) $iBodyTextLimit . '>';
                 }
                 $aFetchItems[] = $sLine;
             }
         }
     }
     if (0 < strlen($sICalMimeIndex)) {
         $aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $sICalMimeIndex . ']';
     }
     if (0 < strlen($sVCardMimeIndex)) {
         $aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $sVCardMimeIndex . ']';
     }
     if (0 < count($aAscPartsIds)) {
         foreach ($aAscPartsIds as $sPartID) {
             $aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $sPartID . ']';
         }
     }
     if (!$oBodyStructure) {
         $aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE;
     }
     $aFetchResponse = $oImapClient->Fetch($aFetchItems, $iUid, true);
     if (0 < count($aFetchResponse)) {
         $oMessage = CApiMailMessage::createInstance($sFolderFullNameRaw, $aFetchResponse[0], $oBodyStructure, $sRfc822SubMimeIndex, $aAscPartsIds);
     }
     if ($oMessage) {
         $sFromEmail = '';
         $oFromCollection = $oMessage->getFrom();
         if ($oFromCollection && 0 < $oFromCollection->Count()) {
             $oFrom =& $oFromCollection->GetByIndex(0);
             if ($oFrom) {
                 $sFromEmail = trim($oFrom->GetEmail());
             }
         }
         if (0 < strlen($sFromEmail)) {
             $oApiUsersManager = CApi::Manager('users');
             $oSettings =& CApi::GetSettings();
             $bAlwaysShowImagesInMessage = !!$oSettings->GetConf('WebMail/AlwaysShowImagesInMessage');
             $oMessage->setSafety($bAlwaysShowImagesInMessage ? true : $oApiUsersManager->getSafetySender($oAccount->IdUser, $sFromEmail, true));
         }
         /*if ($bParseAsc && 0 < count($aAscPartsIds))
         		{
         			
         		}*/
         if ($bParseICalAndVcard) {
             $oApiCapa = CApi::Manager('capability');
             $oApiFileCache = CApi::Manager('filecache');
             // ICAL
             $sICal = $oMessage->getExtend('ICAL_RAW');
             if (!empty($sICal) && $oApiCapa->isCalendarSupported($oAccount)) {
                 $oApiCalendarManager = CApi::Manager('calendar');
                 if ($oApiCalendarManager) {
                     $mResult = $oApiCalendarManager->processICS($oAccount, trim($sICal), $sFromEmail);
                     if (is_array($mResult) && !empty($mResult['Action']) && !empty($mResult['Body'])) {
                         $sTemptFile = md5($mResult['Body']) . '.ics';
                         if ($oApiFileCache && $oApiFileCache->put($oAccount, $sTemptFile, $mResult['Body'])) {
                             $oIcs = CApiMailIcs::createInstance();
                             $oIcs->Uid = $mResult['UID'];
                             $oIcs->Sequence = $mResult['Sequence'];
                             $oIcs->File = $sTemptFile;
                             $oIcs->Attendee = isset($mResult['Attendee']) ? $mResult['Attendee'] : null;
                             $oIcs->Type = $mResult['Action'];
                             $oIcs->Location = !empty($mResult['Location']) ? $mResult['Location'] : '';
                             $oIcs->Description = !empty($mResult['Description']) ? $mResult['Description'] : '';
                             $oIcs->When = !empty($mResult['When']) ? $mResult['When'] : '';
                             $oIcs->CalendarId = !empty($mResult['CalendarId']) ? $mResult['CalendarId'] : '';
                             if (!$oApiCapa->isCalendarAppointmentsSupported($oAccount)) {
                                 $oIcs->Type = 'SAVE';
                             }
                             // TODO
                             //								$oIcs->Calendars = array();
                             //								if (isset($mResult['Calendars']) && is_array($mResult['Calendars']) && 0 < count($mResult['Calendars']))
                             //								{
                             //									foreach ($mResult['Calendars'] as $sUid => $sName)
                             //									{
                             //										$oIcs->Calendars[$sUid] = $sName;
                             //									}
                             //								}
                             $oMessage->addExtend('ICAL', $oIcs);
                         } else {
                             CApi::Log('Can\'t save temp file "' . $sTemptFile . '"', ELogLevel::Error);
                         }
                     }
                 }
             }
             // VCARD
             $sVCard = $oMessage->getExtend('VCARD_RAW');
             if (!empty($sVCard) && $oApiCapa->isContactsSupported($oAccount)) {
                 $oApiContactsManager = CApi::Manager('contacts');
                 $oContact = new CContact();
                 $oContact->InitFromVCardStr($oAccount->IdUser, $sVCard);
                 $oContact->initBeforeChange();
                 $oContact->IdContact = 0;
                 $bContactExists = false;
                 if (0 < strlen($oContact->ViewEmail)) {
                     if ($oApiContactsManager) {
                         $oLocalContact = $oApiContactsManager->getContactByEmail($oAccount->IdUser, $oContact->ViewEmail);
                         if ($oLocalContact) {
                             $oContact->IdContact = $oLocalContact->IdContact;
                             $bContactExists = true;
                         }
                     }
                 }
                 $sTemptFile = md5($sVCard) . '.vcf';
                 if ($oApiFileCache && $oApiFileCache->put($oAccount, $sTemptFile, $sVCard)) {
                     $oVcard = CApiMailVcard::createInstance();
                     $oVcard->Uid = $oContact->IdContact;
                     $oVcard->File = $sTemptFile;
                     $oVcard->Exists = !!$bContactExists;
                     $oVcard->Name = $oContact->FullName;
                     $oVcard->Email = $oContact->ViewEmail;
                     $oMessage->addExtend('VCARD', $oVcard);
                 } else {
                     CApi::Log('Can\'t save temp file "' . $sTemptFile . '"', ELogLevel::Error);
                 }
             }
         }
     }
     return $oMessage;
 }
function w2PgetUsernameFromID($userId)
{
    trigger_error("w2PcontextHelp() has been deprecated in v3.1 and will be removed by v5.0. Please use CContact::getContactByUserid() instead.", E_USER_NOTICE);
    return CContact::getContactByUserid($userId);
}
Example #26
0
	<th><?php 
    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>
Example #27
0
 /**
  * @return array
  */
 public function AjaxContactsSaveVcf()
 {
     $oAccount = $this->getAccountFromParam();
     $mResult = false;
     if (!$this->oApiCapability->isPersonalContactsSupported($oAccount)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::ContactsNotAllowed);
     }
     $sTempFile = (string) $this->getParamValue('File', '');
     if (empty($sTempFile)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
     }
     $oApiFileCache = \CApi::Manager('filecache');
     $sData = $oApiFileCache->get($oAccount, $sTempFile);
     if (!empty($sData)) {
         $oContactsApi = $this->ApiContacts();
         if ($oContactsApi) {
             $oContact = new \CContact();
             $oContact->InitFromVCardStr($oAccount->IdUser, $sData);
             if ($oContactsApi->createContact($oContact)) {
                 $mResult = array('Uid' => $oContact->IdContact);
             }
         }
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }
Example #28
0
 case 'files':
     $title = 'File';
     $q->addQuery('file_id,file_name');
     $q->addOrder('file_name');
     $resultList = $q->loadHashList();
     break;
 case 'forums':
     $title = 'Forum';
     $q->addQuery('forum_id,forum_name');
     $q->addOrder('forum_name');
     $resultList = $q->loadHashList();
     break;
 case 'projects':
     $project_company = w2PgetParam($_GET, 'project_company', 0);
     if ($user_id > 0) {
         $projectList = CContact::getProjects($user_id);
     } else {
         $projectList = CCompany::getProjects($AppUI, $project_company);
     }
     foreach ($projectList as $project) {
         $resultList[$project['project_id']] = $project['project_name'];
     }
     break;
 case 'tasks':
     $title = 'Task';
     $task_project = (int) w2PgetParam($_GET, 'task_project', 0);
     $myTask = new CTask();
     $task_list = $myTask->getAllowedTaskList($AppUI, $task_project);
     $level = 0;
     $query_result = array();
     $last_parent = 0;
Example #29
0
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
$project = new CProject();
$criticalTasks = $project_id > 0 ? $project->getCriticalTasks($project_id) : null;
// pull valid projects and their percent complete information
$projects = $project->getAllowedProjects($AppUI->user_id, false);
##############################################
/* gantt is called now by the todo page, too.
** there is a different filter approach in todo
** so we have to tweak a little bit,
** also we do not have a special project available
*/
$caller = w2PgetParam($_REQUEST, 'caller', null);
if ($caller == 'todo') {
    $user_id = w2PgetParam($_REQUEST, 'user_id', $AppUI->user_id);
    $projects[$project_id]['project_name'] = $AppUI->_('Todo for') . ' ' . CContact::getContactByUserid($user_id);
    $projects[$project_id]['project_color_identifier'] = 'ff6000';
    $showLabels = w2PgetParam($_REQUEST, 'showLabels', false);
    $showPinned = w2PgetParam($_REQUEST, 'showPinned', false);
    $showArcProjs = w2PgetParam($_REQUEST, 'showArcProjs', false);
    $showHoldProjs = w2PgetParam($_REQUEST, 'showHoldProjs', false);
    $showDynTasks = w2PgetParam($_REQUEST, 'showDynTasks', false);
    $showLowTasks = w2PgetParam($_REQUEST, 'showLowTasks', true);
    $q = new DBQuery();
    $q->addQuery('ta.*');
    $q->addQuery('project_name, project_id, project_color_identifier');
    $q->addQuery('tp.task_pinned');
    $q->addTable('projects', 'pr');
    $q->addTable('tasks', 'ta');
    $q->addTable('user_tasks', 'ut');
    $q->leftJoin('user_task_pin', 'tp', 'tp.task_id = ta.task_id and tp.user_id = ' . (int) $user_id);
Example #30
0
 /**
  * @param string $sSql
  * @param int $iUserId = null
  * @param int $iSharedTenantId = null
  * @return CContact
  */
 protected function getContactBySql($sSql, $iUserId = null, $iSharedTenantId = null)
 {
     $oContact = false;
     if ($this->oConnection->Execute($sSql)) {
         $oContact = null;
         $oRow = $this->oConnection->GetNextRecord();
         if ($oRow) {
             $oContact = new CContact();
             $oContact->InitByDbRow($oRow);
             if ($oContact->ReadOnly && null !== $iUserId && (EContactType::Global_ === $oContact->Type || EContactType::GlobalAccounts === $oContact->Type)) {
                 $oGContact = $this->GetMyGlobalContact($iUserId);
                 if ($oGContact && (string) $oContact->IdTypeLink === (string) $oGContact->IdContact) {
                     $oContact->ReadOnly = false;
                     $oContact->ItsMe = true;
                 }
             }
             $this->oConnection->FreeResult();
             $this->updateContactGroupIds($oContact);
         } else {
             $this->oConnection->FreeResult();
         }
     }
     $this->throwDbExceptionIfExist();
     return $oContact;
 }