/** * Delete the selected address */ public function deleteAction() { $addressbook = new AddressBook($_POST); $result = $addressbook->deleteAddress(); $this->redirect('Contacts', 'list'); return $result; }
function addressbook_init($showerr = true, $onlylocal = false) { global $data_dir, $username, $ldap_server, $address_book_global_filename; global $addrbook_dsn, $addrbook_table; /* Create a new addressbook object */ $abook = new AddressBook(); /* Always add a local backend. We use *either* file-based *or* a database addressbook. If $addrbook_dsn is set, the database backend is used. If not, addressbooks are stores in files. */ if (isset($addrbook_dsn) && !empty($addrbook_dsn)) { /* Database */ if (!isset($addrbook_table) || empty($addrbook_table)) { $addrbook_table = 'address'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table)); if (!$r && $showerr) { echo _("Error initializing addressbook database."); exit; } } else { /* File */ $filename = getHashedFile($username, $data_dir, "{$username}.abook"); $r = $abook->add_backend('local_file', array('filename' => $filename, 'create' => true)); if (!$r && $showerr) { printf(_("Error opening file %s"), $filename); exit; } } /* This would be for the global addressbook */ if (isset($address_book_global_filename)) { $r = $abook->add_backend('global_file'); if (!$r && $showerr) { echo _("Error initializing global addressbook."); exit; } } if ($onlylocal) { return $abook; } /* Load configured LDAP servers (if PHP has LDAP support) */ if (isset($ldap_server) && is_array($ldap_server) && function_exists('ldap_connect')) { reset($ldap_server); while (list($undef, $param) = each($ldap_server)) { if (is_array($param)) { $r = $abook->add_backend('ldap_server', $param); if (!$r && $showerr) { printf(' ' . _("Error initializing LDAP server %s:") . "<BR>\n", $param['host']); echo ' ' . $abook->error; exit; } } } } /* Return the initialized object */ return $abook; }
/** * @param $properties * @return Contact|null */ public function createOrUpdate($properties) { $addressBook = $this->getAddressbook(); if (array_key_exists('id', $properties)) { // we must "update" the contact by replacing the entire data set $id = $properties['id']; $contact = $this->addressBook->getChild($properties['id']); foreach (array_keys($properties) as $name) { if (isset($contact->{$name})) { unset($contact->{$name}); } } } else { // the contact doesn't exist // we must create a new one try { $id = $addressBook->addChild(); } catch (\Exception $e) { } $contact = $addressBook->getChild($id); } foreach ($properties as $name => $value) { $contact->setPropertyByName($name, $value); } $contact->save(); return $contact; }
/** * @param $pattern * @param $searchProperties * @param $options * @return array|false */ public function search($pattern, $searchProperties, $options) { $ids = array(); $results = array(); $query = 'SELECT DISTINCT `contactid` FROM `' . self::PROPERTY_TABLE . '` WHERE ('; $params = array(); foreach ($searchProperties as $property) { $params[] = $property; $params[] = '%' . $pattern . '%'; $query .= '(`name` = ? AND `value` LIKE ?) OR '; } $query = substr($query, 0, strlen($query) - 4); $query .= ')'; $stmt = \OCP\DB::prepare($query); $result = $stmt->execute($params); if (\OCP\DB::isError($result)) { \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); return false; } while ($row = $result->fetchRow()) { $ids[] = $row['contactid']; } if (count($ids) > 0) { $query = 'SELECT `' . self::CONTACT_TABLE . '`.`addressbookid`, `' . self::PROPERTY_TABLE . '`.`contactid`, `' . self::PROPERTY_TABLE . '`.`name`, `' . self::PROPERTY_TABLE . '`.`value` FROM `' . self::PROPERTY_TABLE . '`,`' . self::CONTACT_TABLE . '` WHERE `' . self::CONTACT_TABLE . '`.`addressbookid` = \'' . $this->addressBook->getId() . '\' AND `' . self::PROPERTY_TABLE . '`.`contactid` = `' . self::CONTACT_TABLE . '`.`id` AND `' . self::PROPERTY_TABLE . '`.`contactid` IN (' . join(',', array_fill(0, count($ids), '?')) . ')'; \OCP\Util::writeLog('contacts', __METHOD__ . 'DB query: ' . $query, \OCP\Util::DEBUG); $stmt = \OCP\DB::prepare($query); $result = $stmt->execute($ids); } while ($row = $result->fetchRow()) { $this->getProperty($results, $row); } return $results; }
function addContact() { $isOk = new InputBoolean(); $isOk = AddressBook::AddContact($input_name, $input_lastname, $input_email, $input_phone, $input_work, "", $input_message); if ($isOk == true) { echo "Contact added!"; } }
private function addressbooks() { $addressbook = AddressBook::model()->findByAttributes(array('user_id' => $this->from)); $success = true; foreach ($addressbook as $item) { $item->user_id = $this->to; $success = $item->save() && $success; } return $success; }
/** * Format the address book into a format that is easy for template authors * to use * * @param array $addresses all contacts as given by calling $abook->list_addr() * @return array * @author Steve Brown * @since 1.5.2 */ function formatAddressList($addresses) { if (!is_array($addresses) || count($addresses) == 0) { return array(); } $contacts = array(); while (list($undef, $row) = each($addresses)) { $contact = array('FirstName' => sm_encode_html_special_chars($row['firstname']), 'LastName' => sm_encode_html_special_chars($row['lastname']), 'FullName' => sm_encode_html_special_chars($row['name']), 'NickName' => sm_encode_html_special_chars($row['nickname']), 'Email' => sm_encode_html_special_chars($row['email']), 'FullAddress' => sm_encode_html_special_chars(AddressBook::full_address($row)), 'RawFullAddress' => AddressBook::full_address($row), 'Info' => sm_encode_html_special_chars($row['label']), 'Extra' => isset($row['extra']) ? $row['extra'] : NULL, 'Source' => sm_encode_html_special_chars($row['source']), 'JSEmail' => sm_encode_html_special_chars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES)); $contacts[] = $contact; } return $contacts; }
public static function searchProperties($searchquery) { $ids = AddressBook::activeIds(\OCP\USER::getUser()); $id_sql = join(',', array_fill(0, count($ids), '?')); $SQL = "SELECT `c`.`id`,`c`.`fullname`,`cp`.`name`,`cp`.`value` FROM `" . self::ContactsTable . "` c\n\t\t LEFT JOIN `" . self::ContactsProbTable . "` cp ON `c`.`id`=`cp`.`contactid`\n\t\t WHERE `c`.`addressbookid` IN (" . $id_sql . ") AND `cp`.`value` LIKE '%" . addslashes($searchquery) . "%' AND `c`.`component`='VCARD' GROUP BY `c`.`id`"; $stmt = \OCP\DB::prepare($SQL); //array_push($ids,$searchquery); $result = $stmt->execute($ids); $cards = array(); if (!is_null($result)) { while ($row = $result->fetchRow()) { //if($row['']) $cards[] = $row; } } return $cards; }
/** * List search results * @param array $res Array containing results of search * @param bool $includesource If true, adds backend column to address listing */ function addr_display_result($res, $includesource = true) { global $color, $javascript_on, $PHP_SELF, $squirrelmail_language; if (sizeof($res) <= 0) { return; } echo addForm($PHP_SELF, 'POST', 'addrbook') . addHidden('html_addr_search_done', 'true'); addr_insert_hidden(); $line = 0; if ($javascript_on) { print '<script language="JavaScript" type="text/javascript">' . "\n<!-- \n" . "function CheckAll(ch) {\n" . " for (var i = 0; i < document.addrbook.elements.length; i++) {\n" . " if( document.addrbook.elements[i].type == 'checkbox' &&\n" . " document.addrbook.elements[i].name.substr(0,16) == 'send_to_search['+ch ) {\n" . " document.addrbook.elements[i].checked = !(document.addrbook.elements[i].checked);\n" . " }\n" . " }\n" . "}\n" . "//-->\n" . "</script>\n"; $chk_all = '<a href="#" onClick="CheckAll(\'T\');">' . _("All") . '</a> <font color="' . $color[9] . '">' . _("To") . '</font>' . ' ' . '<a href="#" onClick="CheckAll(\'C\');">' . _("All") . '</a> <font color="' . $color[9] . '">' . _("Cc") . '</font>' . ' ' . '<a href="#" onClick="CheckAll(\'B\');">' . _("All") . '</a>'; } else { // check_all links are implemented only in JavaScript. disable links in js=off environment. $chk_all = ''; } echo html_tag('table', '', 'center', '', 'border="0" width="98%"') . html_tag('tr', '', '', $color[9]) . html_tag('th', ' ' . $chk_all, 'left') . html_tag('th', ' ' . _("Name"), 'left') . html_tag('th', ' ' . _("E-mail"), 'left') . html_tag('th', ' ' . _("Info"), 'left'); if ($includesource) { echo html_tag('th', ' ' . _("Source"), 'left', '', 'width="10%"'); } echo "</tr>\n"; foreach ($res as $row) { $email = AddressBook::full_address($row); if ($line % 2) { $tr_bgcolor = $color[12]; } else { $tr_bgcolor = $color[4]; } if ($squirrelmail_language == 'ja_JP') { echo html_tag('tr', '', '', $tr_bgcolor, 'nowrap') . html_tag('td', '<input type="checkbox" name="send_to_search[T' . $line . ']" value = "' . htmlspecialchars($email) . '" /> ' . _("To") . ' ' . '<input type="checkbox" name="send_to_search[C' . $line . ']" value = "' . htmlspecialchars($email) . '" /> ' . _("Cc") . ' ' . '<input type="checkbox" name="send_to_search[B' . $line . ']" value = "' . htmlspecialchars($email) . '" /> ' . _("Bcc") . ' ', 'center', '', 'width="5%" nowrap') . html_tag('td', ' ' . htmlspecialchars($row['lastname']) . ' ' . htmlspecialchars($row['firstname']) . ' ', 'left', '', 'nowrap') . html_tag('td', ' ' . htmlspecialchars($row['email']) . ' ', 'left', '', 'nowrap') . html_tag('td', ' ' . htmlspecialchars($row['label']) . ' ', 'left', '', 'nowrap'); } else { echo html_tag('tr', '', '', $tr_bgcolor, 'nowrap') . html_tag('td', addCheckBox('send_to_search[T' . $line . ']', FALSE, $email) . ' ' . _("To") . ' ' . addCheckBox('send_to_search[C' . $line . ']', FALSE, $email) . ' ' . _("Cc") . ' ' . addCheckBox('send_to_search[B' . $line . ']', FALSE, $email) . ' ' . _("Bcc") . ' ', 'center', '', 'width="5%" nowrap') . html_tag('td', ' ' . htmlspecialchars($row['name']) . ' ', 'left', '', 'nowrap') . html_tag('td', ' ' . htmlspecialchars($row['email']) . ' ', 'left', '', 'nowrap') . html_tag('td', ' ' . htmlspecialchars($row['label']) . ' ', 'left', '', 'nowrap'); } if ($includesource) { echo html_tag('td', ' ' . $row['source'] . ' ', 'left', '', 'nowrap'); } echo "</tr>\n"; $line++; } if ($includesource) { $td_colspan = '5'; } else { $td_colspan = '4'; } echo html_tag('tr', html_tag('td', '<input type="submit" name="addr_search_done" value="' . _("Use Addresses") . '" /> ' . '<input type="submit" name="addr_search_cancel" value="' . _("Cancel") . '" />', 'center', '', 'colspan="' . $td_colspan . '"')) . '</table>' . addHidden('html_addr_search_done', '1') . '</form>'; }
/** * view data order / detail data order */ public function actionView($id) { /* untuk cek login admin */ IsAuth::Admin(); /* panggil function loadModel() * dan ditampung ke $dataOrder */ $dataOrder = $this->loadModel($id); /* find data confirmpayment berdasarkan order_code */ $dataConfirmPayment = ConfirmPayment::model()->findByAttributes(array('order_code' => $dataOrder->order_code)); /* find data alamat pengiriman berdasarkan id_address */ $dataShippingAddress = AddressBook::model()->findByPk($dataOrder->address_book_id); /* panggil model Orderdetail dan function search */ $model = new Orderdetail('search'); /* clear any default values */ $model->unsetAttributes(); /* set select data order_detail berdasarkan order_code */ $model->order_code = $dataOrder->order_code; /* render ke file views/orders/view */ $this->render('view', array('model' => $dataOrder, 'ordet' => $model, 'dataPayment' => $dataConfirmPayment, 'shippingAddress' => $dataShippingAddress)); }
?> <input type="text" name="organization_note" class="select2field" id="select2field" /> <?php } ?> <p> <table class="table table-striped table-bordered table-condensed" id="contact_list"> <thead> <th>Наименование</th> <th>Адрес организации</th> <th>Телефон</th> <th>Email</th> </thead> <tbody> <?php $organizationData = new AddressBook(); $dataOrganization = $organizationData->getOrganizationDetails($rows->organization_id); foreach ($dataOrganization as $organization_value) { echo '<tr>' . '<td>' . anchor("addressbook/viewOrganizationDetails/" . $organization_value->id, $organization_value->organization_name) . '</td>' . '<td>' . $organization_value->address . '</td>' . '<td>' . $organization_value->phone_number . '</td>' . '<td>' . $organization_value->email . '</td>' . '<input type="hidden" name="organizationid" value="' . $organization_value->id . '" />' . '</tr>'; } ?> </tbody> </table> </p> </div> </div> <!-- Button (Double) --> <div class="control-group"> <label class="control-label" for="submit"></label> <div class="controls">
/** * @param $properties * @return mixed */ public function createOrUpdate($properties) { $id = null; /** * @var \OCA\Contacts\VObject\VCard */ $vcard = null; if (array_key_exists('id', $properties)) { // TODO: test if $id belongs to this addressbook $id = $properties['id']; // TODO: Test $vcard $vcard = $this->addressBook->getChild($properties['id']); foreach (array_keys($properties) as $name) { if (isset($vcard->{$name})) { unset($vcard->{$name}); } } } else { $vcard = \Sabre\VObject\Component::create('VCARD'); $uid = substr(md5(rand() . time()), 0, 10); $vcard->add('UID', $uid); try { $id = $this->addressBook->addChild($vcard); } catch (\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ' ' . $e->getMessage(), \OCP\Util::ERROR); return false; } } foreach ($properties as $name => $value) { switch ($name) { case 'ADR': case 'N': if (is_array($value)) { $property = \Sabre\VObject\Property::create($name); $property->setParts($value); $vcard->add($property); } else { $vcard->{$name} = $value; } break; case 'BDAY': // TODO: try/catch $date = new \DateTime($value); $vcard->BDAY = $date->format('Y-m-d'); $vcard->BDAY->VALUE = 'DATE'; break; case 'EMAIL': case 'TEL': case 'IMPP': // NOTE: We don't know if it's GTalk, Jabber etc. only the protocol // NOTE: We don't know if it's GTalk, Jabber etc. only the protocol case 'URL': if (is_array($value)) { foreach ($value as $val) { $vcard->add($name, strip_tags($val)); } } else { $vcard->add($name, strip_tags($value)); } default: $vcard->{$name} = $value; break; } } try { VCard::edit($id, $vcard); } catch (\Exception $e) { \OCP\Util::writeLog('contacts', __METHOD__ . ' ' . $e->getMessage(), \OCP\Util::ERROR); return false; } $asarray = VCard::structureContact($vcard); $asarray['id'] = $id; return $asarray; }
/** * Scan vCards for properties. */ public static function indexProperties() { $offset = 0; $limit = 10; $app = new App(); $backend = $app->getBackend('local'); $addressBookInfos = $backend->getAddressBooksForUser(); foreach ($addressBookInfos as $addressBookInfo) { $addressBook = new AddressBook($backend, $addressBookInfo); while ($contacts = $addressBook->getChildren($limit, $offset, false)) { foreach ($contacts as $contact) { $contact->retrieve(); } \OCP\Util::writeLog('contacts', __CLASS__ . '::' . __METHOD__ . ', indexing: ' . $limit . ' starting from ' . $offset, \OCP\Util::DEBUG); Utils\Properties::updateIndex($contact->getId(), $contact); $offset += $limit; } } }
/** Create and initialize an addressbook object. Returns the created object */ function addressbook_init($showerr = true, $onlylocal = false) { global $data_dir, $username, $color, $ldap_server, $address_book_global_filename; global $addrbook_dsn, $addrbook_table; // Shared file based address book globals global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing; // Shared DB based address book globals global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing; // Record size restriction in file based address books global $abook_file_line_length; /* Create a new addressbook object */ $abook = new AddressBook(); /* Create empty error message */ $abook_init_error = ''; /* Always add a local backend. We use *either* file-based *or* a database addressbook. If $addrbook_dsn is set, the database backend is used. If not, addressbooks are stores in files. */ if (isset($addrbook_dsn) && !empty($addrbook_dsn)) { /* Database */ if (!isset($addrbook_table) || empty($addrbook_table)) { $addrbook_table = 'address'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table)); if (!$r && $showerr) { $abook_init_error .= _("Error initializing address book database.") . ' ' . $abook->error; } } else { /* File */ $filename = getHashedFile($username, $data_dir, "{$username}.abook"); $r = $abook->add_backend('local_file', array('filename' => $filename, 'line_length' => $abook_file_line_length, 'create' => true)); if (!$r && $showerr) { $abook_init_error .= sprintf(_("Error opening file %s"), $filename); } } /* This would be for the global addressbook */ if (isset($abook_global_file) && isset($abook_global_file_writeable) && trim($abook_global_file) != '') { // Detect place of address book if (!preg_match("/[\\/\\\\]/", $abook_global_file)) { /* no path chars, address book stored in data directory * make sure that there is a slash between data directory * and address book file name */ $abook_global_filename = $data_dir . (substr($data_dir, -1) != '/' ? '/' : '') . $abook_global_file; } elseif (preg_match("/^\\/|\\w:/", $abook_global_file)) { // full path is set in options (starts with slash or x:) $abook_global_filename = $abook_global_file; } else { $abook_global_filename = SM_PATH . $abook_global_file; } $r = $abook->add_backend('local_file', array('filename' => $abook_global_filename, 'name' => _("Global address book"), 'detect_writeable' => false, 'line_length' => $abook_file_line_length, 'writeable' => $abook_global_file_writeable, 'listing' => $abook_global_file_listing)); if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error; } } /* Load global addressbook from SQL if configured */ if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) { /* Database configured */ if (!isset($addrbook_global_table) || empty($addrbook_global_table)) { $addrbook_global_table = 'global_abook'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_global_dsn, 'owner' => 'global', 'name' => _("Global address book"), 'writeable' => $addrbook_global_writeable, 'listing' => $addrbook_global_listing, 'table' => $addrbook_global_table)); if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error; } } /* * hook allows to include different address book backends. * plugins should extract $abook and $r from arguments * and use same add_backend commands as above functions. * @since 1.5.1 and 1.4.5 */ $hookReturn = do_hook('abook_init', $abook, $r); $abook = $hookReturn[1]; $r = $hookReturn[2]; if (!$onlylocal) { /* Load configured LDAP servers (if PHP has LDAP support) */ if (isset($ldap_server) && is_array($ldap_server) && function_exists('ldap_connect')) { reset($ldap_server); while (list($undef, $param) = each($ldap_server)) { if (is_array($param)) { $r = $abook->add_backend('ldap_server', $param); if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= sprintf(_("Error initializing LDAP server %s:") . "\n", $param['host']); $abook_init_error .= $abook->error; } } } } } // end of remote abook backends init /** * display address book init errors. */ if ($abook_init_error != '' && $showerr) { $abook_init_error = htmlspecialchars($abook_init_error); error_box($abook_init_error, $color); } /* Return the initialized object */ return $abook; }
/** * List search results * @param array $res Array of search results * @param bool $includesource [Default=true] * @return void */ function display_result($res, $includesource = true) { global $color; if (sizeof($res) <= 0) { return; } insert_javascript(); $line = 0; echo html_tag('table', '', 'center', '', 'border="0" width="98%"') . html_tag('tr', '', '', $color[9]) . html_tag('th', ' ', 'left') . html_tag('th', ' ' . _("Name"), 'left') . html_tag('th', ' ' . _("E-mail"), 'left') . html_tag('th', ' ' . _("Info"), 'left'); if ($includesource) { echo html_tag('th', ' ' . _("Source"), 'left', '', 'width="10%"'); } echo "</tr>\n"; while (list($undef, $row) = each($res)) { $email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES); if ($line % 2) { $tr_bgcolor = $color[12]; } else { $tr_bgcolor = $color[4]; } echo html_tag('tr', '', '', $tr_bgcolor, 'nowrap') . html_tag('td', '<small><a href="javascript:to_address(' . "'" . $email . "');\">" . _("To") . "</a> | " . '<a href="javascript:cc_address(' . "'" . $email . "');\">" . _("Cc") . "</a> | " . '<a href="javascript:bcc_address(' . "'" . $email . "');\">" . _("Bcc") . "</a></small>", 'center', '', 'valign="top" width="5%" nowrap') . html_tag('td', ' ' . htmlspecialchars($row['name']), 'left', '', 'valign="top" nowrap') . html_tag('td', ' ' . '<a href="javascript:to_and_close(' . "'" . $email . "');\">" . htmlspecialchars($row['email']) . '</a>', 'left', '', 'valign="top"') . html_tag('td', htmlspecialchars($row['label']), 'left', '', 'valign="top" nowrap'); if ($includesource) { echo html_tag('td', ' ' . $row['source'], 'left', '', 'valign="top" nowrap'); } echo "</tr>\n"; $line++; } echo '</table>'; }
/** * Show the form for creating a new resource. * * @return Response */ public function acceptCase($id) { $caseOwnerObj = CaseOwner::where("caseId", '=', $id)->where("user", '=', \Auth::user()->id)->first(); $numberCases = CaseReport::where('user', '=', \Auth::user()->id)->get(); if (sizeof($caseOwnerObj) > 0) { $caseOwnerObj->accept = 1; $caseOwnerObj->save(); $caseActivity = new CaseActivity(); $caseActivity->caseId = $id; $caseActivity->user = \Auth::user()->id; $caseActivity->addressbook = 0; $caseActivity->note = "Case Accepted by " . \Auth::user()->name . ' ' . \Auth::user()->surname; $caseActivity->save(); $case = CaseReport::find($id); if ($case->status == "Pending") { $case->status = "Actioned"; $case->accepted_at = \Carbon\Carbon::now('Africa/Johannesburg')->toDateTimeString(); $case->save(); } $caseOwners = CaseOwner::where("caseId", '=', $id)->where("user", "<>", \Auth::user()->id)->get(); foreach ($caseOwners as $owner) { if ($owner->addressbook == 1) { $user = AddressBook::find($owner->user); } else { $user = User::find($owner->user); } $data = array('name' => $user->name, 'caseID' => $id, 'acceptedBy' => \Auth::user()->name . ' ' . \Auth::user()->surname); \Mail::send('emails.acceptCase', $data, function ($message) use($user) { $message->from('*****@*****.**', 'Siyaleader'); $message->to($user->username)->subject("Siyaleader Notification - New Case Accepted: "); }); } } return "ok"; }
<?php /* * Primitive Fields repeated */ // first include pb_message require_once '../../message/pb_message.php'; // include the generated file require_once './pb_proto_primitive.php'; $book = new AddressBook(); $book->append_person("Hello"); $book->append_person("Test"); $book->append_type(AddressBook_PhoneType::MOBILE); // in $ p now there is Hello $p = $book->person(0); var_dump($p); $string = $book->SerializeToString(); // now test the reading $book = new AddressBook(); $book->parseFromString($string); var_dump($book->person(0)); var_dump($book->person_size()); var_dump($book->person(1)); var_dump($book->type(0) == AddressBook_PhoneType::MOBILE);
<?php echo $row->comment; ?> </td> </tr> <?php } ?> <?php if ($row->organization_id !== '') { ?> <tr> <th scope="row">Организация</th> <td> <?php $organizationDetails = new AddressBook(); $data = $organizationDetails->getOrganizationDetails($row->organization_id); foreach ($data as $organizationRow) { echo anchor("addressbook/viewOrganizationDetails/" . $row->organization_id, $organizationRow->organization_name); echo form_button('deleteFromOrganization', '<i class="icon-trash"> </i>Удалить из организации', 'class="btn btn-danger btn-mini pull-right" onclick="deleteFromOrganization(' . $row->id . '); return false;"'); } ?> </td> </tr> <tr> <th data-toggle="collapse" data-target="#demo1" class="accordion-toggle" scope="row">Местоположение на карте ...</th> <td class="hiddenRow"> <div class="accordian-body collapse" id="demo1"> <?php echo $map['js']; echo $map['html'];
function actionFinishshop() { /* jika customer tidak login maka direct * ke halaman account untuk login */ if (!isset(Yii::app()->user->customerLogin)) { $this->redirect(array('/account')); } /* jika add new address */ if (isset($_GET['addNewAddress'])) { /* panggil model address */ $modelAddress = new AddressBook(); /* jika data address dikirim maka */ if (isset($_POST['AddressBook'])) { /* set attributes */ $modelAddress->attributes = $_POST['AddressBook']; /* set field customer_id untuk data address */ $modelAddress->customer_id = Yii::app()->user->customerId; /* jika disimpan maka */ if ($modelAddress->save()) { /* set session id_address */ $_SESSION['address_book_id'] = Yii::app()->db->getLastInsertID(); /* render ke view payment/transfer bank * untuk memilih jenis pembayaran */ $this->render("payment"); return; } } /* jika data transfer bank/payment dikirim maka */ if (isset($_POST['Transfer'])) { /* set var bank_transfer */ $this->bank_transfer = $_POST['Transfer']['bank']; /* set var id_address */ $this->address_book_id = $_SESSION['address_book_id']; /* add order dan hapus data yang ada dikeanjang belanja */ $this->addOrderCleanCart(); return; } /* render view untuk form add new address */ $this->render('addNewAddress', array('model' => $modelAddress)); return; } /* jika memilih address * yang sudah ada */ if (isset($_POST['ChooseAddress'])) { /* set session id_address */ $_SESSION['address_book_id'] = $_POST['ChooseAddress']['address_book_id']; /* render ke view payment/transfer bank */ $this->render("payment"); return; } /* jika transfer maka */ if (isset($_POST['Transfer'])) { /* set var bank_transfer */ $this->bank_transfer = $_POST['Transfer']['bank']; /* set var id_address */ $this->address_book_id = $_SESSION['address_book_id']; /* add order dan hapus data yang ada dikeanjang belanja */ $this->addOrderCleanCart(); return; } /* dapatkan semua data address berdasarkan * user yang login untuk ditampilkan */ $getAddressBooks = AddressBook::model()->findAll('customer_id=:customer_id', array(':customer_id' => Yii::app()->user->customerId)); /* render ke halaman finishop */ $this->render('finishshop', array('addressBooks' => $getAddressBooks)); }
<?php // EXECUTE test_new.php first // first include pb_message require_once '../message/pb_message.php'; // now read it with the old file // include the generated file require_once './pb_proto_test.php'; $string = file_get_contents('./test.pb'); // Just read it $book = new AddressBook(); $book->parseFromString($string); var_dump($book->persons_size()); $person = $book->person(0); var_dump($person->name()); $person = $book->person(1); var_dump($person->name()); var_dump($person->phone(0)->number()); var_dump($person->phone(0)->type()); var_dump($person->phone(1)->number()); var_dump($person->phone(1)->type()); var_dump($person->phone(2)->number()); var_dump($person->phone(2)->type());
/** * displayNewUserHome * * @param int $userid * * @return boolean */ function displayNewUserHome($userid) { include_once 'addressbook_class.php'; $addressObj = new AddressBook($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser); $userid = (int) $userid; $sql = "SELECT `id`\n FROM `fcms_alerts` \n WHERE `alert` = 'alert_new_user_home'\n AND `user` = ? \n AND `hide` = 1"; $row = $this->fcmsDatabase->getRow($sql, $userid); if ($row === false) { $this->fcmsError->displayError(); return false; } if (count($row) >= 1) { return false; } $sitename = getSiteName(); $sitename = cleanOutput($sitename); $complete = 0; // social media $social = '<a href="settings.php?view=socialmedia">' . T_('Connect social media sites') . '</a>'; if (userConnectedSocialMedia($userid)) { $social = '<span>' . T_('Connect social media sites') . '</span>'; $complete++; } // add profile pic $profilePicture = '<span>' . T_('Add a Profile Picture') . '</span>'; $complete++; $avatar = getCurrentAvatar($userid); $checkUploadsPath = 'uploads/avatar/no_avatar.jpg'; if (defined('UPLOADS')) { $checkUploadsPath = 'file.php?a=no_avatar.jpg'; } if ($avatar == $checkUploadsPath) { $profilePicture = '<a href="profile.php?view=picture">' . T_('Add a Profile Picture') . '</a>'; $complete--; } // update contact info $address = '<a href="addressbook.php?cat=all&edit=' . $userid . '">' . T_('Add your Address/Contact information') . '</a>'; if ($addressObj->userhasAddress($userid)) { $address = '<span>' . T_('Add your Address/Contact information') . '</span>'; $complete++; } // vote $sql = "SELECT MAX(`id`) AS 'max'\n FROM `fcms_polls`"; $r = $this->fcmsDatabase->getRow($sql); if ($r === false) { $this->fcmsError->displayError(); return; } $currentPoll = $r['max']; $sql = "SELECT `id`\n FROM `fcms_poll_votes`\n WHERE `user` = ?\n AND `poll_id` = ?"; $rows = $this->fcmsDatabase->getRows($sql, array($userid, $currentPoll)); if ($rows === false) { $this->fcmsError->displayError(); return; } $poll = '<a href="polls.php">' . T_('Vote on the Poll') . '</a>'; if (count($rows) > 0) { $poll = '<span>' . T_('Vote on the Poll') . '</span>'; $complete++; } $percent = $complete / 4 * 100; echo ' <div id="alert_new_user_home" class="info-alert"> <h2>' . T_('It looks like you\'re new here.') . '</h2> <p>' . T_('Complete the following list to get the most out of the site:') . '</p> <small>' . sprintf(T_('Your profile is %s complete.'), $percent) . '</small> <div id="progress"><div style="width: ' . $percent . '%"></div></div> <ol class="todo"> <li>' . $social . '</a></li> <li>' . $profilePicture . '</a></li> <li>' . $address . '</li> <li>' . $poll . '</li> </ol> <p style="text-align:right"><a id="new_admin" href="?alert=alert_new_user_home">' . T_('Skip This and get right to the app.') . '</a></p> </div>'; return true; }
<?php // first include pb_message require_once '../message/pb_message.php'; // include the generated file require_once './pb_proto_test_new.php'; // generate message with the new definition with surname // now just test the classes $book = new AddressBook(); $person = $book->add_person(); $person->set_name('Nikolai'); $person = $book->add_person(); $person->set_name('Kordulla'); $person->set_surname('MySurname'); $phone_number = $person->add_phone(); $phone_number->set_number('0711'); $phone_number->set_type(Person_PhoneType::WORK); $phone_number = $person->add_phone(); $phone_number->set_number('0171'); $phone_number->set_type(Person_PhoneType::MOBILE); $phone_number = $person->add_phone(); $phone_number->set_number('030'); // serialize $string = $book->SerializeToString(); // write it to disk file_put_contents('test.pb', $string);
<?php $book = new AddressBook(); $person = 'Rasmus Lerdorf'; $book->add($person);
/** * Scan vCards for properties. */ public static function indexProperties() { $offset = 0; $limit = 10; $app = new App(); $backend = $app->getBackend('local'); $addressBookInfos = $backend->getAddressBooksForUser(); foreach ($addressBookInfos as $addressBookInfo) { $addressBook = new AddressBook($backend, $addressBookInfo); $contacts = $addressBook->getChildren($limit, $offset, false); \OCP\Util::writeLog('contacts', __METHOD__ . ', indexing: ' . $limit . ' starting from ' . $offset, \OCP\Util::DEBUG); foreach ($contacts as $contact) { if (!$contact->retrieve()) { \OCP\Util::writeLog('contacts', __METHOD__ . ', Error loading contact ' . print_r($contact, true), \OCP\Util::DEBUG); } Utils\Properties::updateIndex($contact->getId(), $contact); } $offset += $limit; } $stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_cards_properties` WHERE NOT EXISTS(SELECT NULL FROM `*PREFIX*contacts_cards` WHERE `*PREFIX*contacts_cards`.id = `*PREFIX*contacts_cards_properties`.contactid)'); $result = $stmt->execute(array()); }
<body> <div class="container-fluid"> <div class="row"> <div class="span10"> <h3 style="color:#08c;">Адресная книга</h3> <?php $groupButton = new AddressBook(); $groupButton->createGroupButton(); ?> <div class="span4"> <div class="btn-toolbar pull-left"> <ul class="nav nav-pills"> <?php echo anchor("addressbook/", "<i class='icon-home'> </i>Организации", array('class' => 'btn btn-small')); ?> <?php echo anchor("addressbook/allContacts", "<i class='icon-user'> </i>Контакты", array('class' => 'btn btn-small')); ?> </ul> </div> </div> <table class="table table-striped table-bordered table-condensed" id='allContactsTable'> <thead> <th>#</th> <th>Наименование</th> <th>Телефон (осн.)</th> <th>Email</th> <th>Адрес</th> <th>Контакты</th> <th>События</th> </thead>
/** * Constructor * * @param Backend\BackendInterface $carddavBackend * @param array $addressBookInfo */ public function __construct(\Sabre\CardDAV\Backend\BackendInterface $carddavBackend, array $addressBookInfo, $principalUri) { parent::__construct($carddavBackend, $addressBookInfo); $this->principalUri = $principalUri; }
/** Create and initialize an addressbook object. Returns the created object */ function addressbook_init($showerr = true, $onlylocal = false) { global $data_dir, $username, $ldap_server, $address_book_global_filename; global $addrbook_dsn, $addrbook_table; global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing; /* Create a new addressbook object */ $abook = new AddressBook(); /* Always add a local backend. We use *either* file-based *or* a database addressbook. If $addrbook_dsn is set, the database backend is used. If not, addressbooks are stores in files. */ if (isset($addrbook_dsn) && !empty($addrbook_dsn)) { /* Database */ if (!isset($addrbook_table) || empty($addrbook_table)) { $addrbook_table = 'address'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table)); if (!$r && $showerr) { echo _("Error initializing addressbook database."); exit; } } else { /* File */ $filename = getHashedFile($username, $data_dir, "{$username}.abook"); $r = $abook->add_backend('local_file', array('filename' => $filename, 'create' => true)); if (!$r && $showerr) { printf(_("Error opening file %s"), $filename); exit; } } /* This would be for the global addressbook */ if (isset($address_book_global_filename)) { $r = $abook->add_backend('global_file'); if (!$r && $showerr) { echo _("Error initializing global addressbook."); exit; } } /* Load global addressbook from SQL if configured */ if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) { /* Database configured */ if (!isset($addrbook_global_table) || empty($addrbook_global_table)) { $addrbook_global_table = 'global_abook'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_global_dsn, 'owner' => 'global', 'name' => _("Global address book"), 'writeable' => $addrbook_global_writeable, 'listing' => $addrbook_global_listing, 'table' => $addrbook_global_table)); } /* * hook allows to include different address book backends. * plugins should extract $abook and $r from arguments * and use same add_backend commands as above functions. */ $hookReturn = do_hook('abook_init', $abook, $r); $abook = $hookReturn[1]; $r = $hookReturn[2]; if ($onlylocal) { return $abook; } /* Load configured LDAP servers (if PHP has LDAP support) */ if (isset($ldap_server) && is_array($ldap_server) && function_exists('ldap_connect')) { reset($ldap_server); while (list($undef, $param) = each($ldap_server)) { if (is_array($param)) { $r = $abook->add_backend('ldap_server', $param); if (!$r && $showerr) { printf(' ' . _("Error initializing LDAP server %s:") . "<br />\n", $param['host']); echo ' ' . $abook->error; exit; } } } } /* Return the initialized object */ return $abook; }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/application/modules/addressBook.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/application/modules/viewer.php'; set_time_limit(0); try { $addressBook = new AddressBook(); while (true) { $timestamp = isset($_GET['timestamp']) ? (int) $_GET['timestamp'] : null; clearstatcache(); if ($timestamp == null || $addressBook->getTimestamp() > $timestamp) { clearstatcache(); switch ($_SERVER['REQUEST_METHOD']) { case 'GET': if (isset($_GET['act']) && $_GET['act'] == 'ajax') { header('Content-Type: application/json'); echo json_encode(array('data' => $addressBook->get(), 'timestamp' => $addressBook->getTimestamp())); } else { Viewer::view('contacts'); } break; case 'PUT': $data = file_get_contents('php://input'); $addressBook->create(new Contact($data['id'], $data['name'], $data['phone'])); break; case 'DELETE': $data = file_get_contents('php://input'); $addressBook->delete(new Contact($data['id'], $data['name'], $data['phone'])); break; default: header('HTTP/1.1 405 Unsupported method');
/** * Create and initialize an addressbook object. * @param boolean $showerr display any address book init errors. html page header * must be created before calling addressbook_init() with $showerr enabled. * @param boolean $onlylocal enable only local address book backends. Should * be used when code does not need access to remote backends. Backends * that provide read only address books with limited listing options can be * tagged as remote. * @return object address book object. */ function addressbook_init($showerr = true, $onlylocal = false) { global $data_dir, $username, $ldap_server, $address_book_global_filename; global $addrbook_dsn, $addrbook_table; global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing; global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing; global $abook_file_line_length; /* Create a new addressbook object */ $abook = new AddressBook(); /* Create empty error message */ $abook_init_error = ''; /* Always add a local backend. We use *either* file-based *or* a database addressbook. If $addrbook_dsn is set, the database backend is used. If not, addressbooks are stores in files. */ if (isset($addrbook_dsn) && !empty($addrbook_dsn)) { /* Database */ if (!isset($addrbook_table) || empty($addrbook_table)) { $addrbook_table = 'address'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table)); if (!$r && $showerr) { $abook_init_error .= _("Error initializing address book database.") . "\n" . $abook->error; } } else { /* File */ $filename = getHashedFile($username, $data_dir, "{$username}.abook"); $r = $abook->add_backend('local_file', array('filename' => $filename, 'umask' => 077, 'line_length' => $abook_file_line_length, 'create' => true)); if (!$r && $showerr) { // no need to use $abook->error, because message explains error. $abook_init_error .= sprintf(_("Error opening file %s"), $filename); } } /* Global file based addressbook */ if (isset($abook_global_file) && isset($abook_global_file_writeable) && isset($abook_global_file_listing) && trim($abook_global_file) != '') { // Detect place of address book if (!preg_match("/[\\/\\\\]/", $abook_global_file)) { /* no path chars, address book stored in data directory * make sure that there is a slash between data directory * and address book file name */ $abook_global_filename = $data_dir . (substr($data_dir, -1) != '/' ? '/' : '') . $abook_global_file; } elseif (preg_match("/^\\/|\\w:/", $abook_global_file)) { // full path is set in options (starts with slash or x:) $abook_global_filename = $abook_global_file; } else { $abook_global_filename = SM_PATH . $abook_global_file; } $r = $abook->add_backend('local_file', array('filename' => $abook_global_filename, 'name' => _("Global Address Book"), 'detect_writeable' => false, 'line_length' => $abook_file_line_length, 'writeable' => $abook_global_file_writeable, 'listing' => $abook_global_file_listing)); /* global abook init error is not fatal. add error message and continue */ if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error; } } /* Load global addressbook from SQL if configured */ if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) { /* Database configured */ if (!isset($addrbook_global_table) || empty($addrbook_global_table)) { $addrbook_global_table = 'global_abook'; } $r = $abook->add_backend('database', array('dsn' => $addrbook_global_dsn, 'owner' => 'global', 'name' => _("Global Address Book"), 'writeable' => $addrbook_global_writeable, 'listing' => $addrbook_global_listing, 'table' => $addrbook_global_table)); /* global abook init error is not fatal. add error message and continue */ if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error; } } /* * hook allows to include different address book backends. * plugins should extract $abook and $r from arguments * and use same add_backend commands as above functions. * Since 1.5.2 hook sends third ($onlylocal) argument to address book * plugins in order to allow detection of local address book init. * @since 1.5.1 and 1.4.5 * Since 1.5.2, the plugin arguments are passed inside an array * and by reference, so plugins hooking in here need to accept arguments * in an array and change those values as needed instead of returning * the changed values. */ $temp = array(&$abook, &$r, &$onlylocal); do_hook('abook_init', $temp); if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= _("Error initializing other address books.") . "\n" . $abook->error; } /* Load configured LDAP servers (if PHP has LDAP support) */ if (isset($ldap_server) && is_array($ldap_server)) { reset($ldap_server); while (list($undef, $param) = each($ldap_server)) { if (!is_array($param)) { continue; } /* if onlylocal is true, we only add writeable ldap servers */ if ($onlylocal && (!isset($param['writeable']) || $param['writeable'] != true)) { continue; } $r = $abook->add_backend('ldap_server', $param); if (!$r && $showerr) { if ($abook_init_error != '') { $abook_init_error .= "\n"; } $abook_init_error .= sprintf(_("Error initializing LDAP server %s:"), $param['host']) . "\n"; $abook_init_error .= $abook->error; } } } // end of ldap server init /** * display address book init errors. */ if ($abook_init_error != '' && $showerr) { error_box(nl2br(sm_encode_html_special_chars($abook_init_error))); } /* Return the initialized object */ return $abook; }
public function actionAddressbook() { /* cek user login */ IsAuth::Customer(); /* jika add data address book */ if (isset($_GET['add'])) { $model = new AddressBook(); /* jika post addressbook */ if (isset($_POST['AddressBook'])) { /* set attributes address book */ $model->attributes = $_POST['AddressBook']; /* ambil customer id */ $model->customer_id = Yii::app()->user->customerId; /* ambil address nama */ $addressName = $_POST['AddressBook']['entry_name']; /* jika berhasil menyimpan data */ if ($model->save()) { /* buat setflash */ Yii::app()->user->setFlash('success', 'New Address with name <b>' . $addressName . '</b> successfully added'); /* direct ke halaman addressbook awal */ $this->redirect(array('account/addressbook')); } } /* render ke view form add addressbook dengan nama(add_addressbook.php) */ $this->render('add_addressbook', array('model' => $model)); return; } /* jika edit address book */ if (isset($_GET['edit'])) { /* ambil data addressbook berdasarkan pk */ $model = AddressBook::model()->findByPk($_GET['edit']); /* jika post Address */ if (isset($_POST['AddressBook'])) { /* ambil nilai attributes nya */ $model->attributes = $_POST['AddressBook']; /* ambil customer id */ $model->customer_id = Yii::app()->user->customerId; /* ambil address name */ $addressName = $_POST['AddressBook']['entry_name']; /* jika berhasil menyimpan data */ if ($model->save()) { /* buat Setflash */ Yii::app()->user->setFlash('success', 'Address book with name <b>' . $addressName . '</b> has been changed'); /* direct ke halaman address book awal */ $this->redirect(array('account/addressbook')); } } /* render ke view form edit address book dengan nama(add_addressbook.php) */ $this->render('add_addressbook', array('model' => $model)); return; } /* untuk menampilkan list data address book */ $model = AddressBook::model()->findAll('customer_id=:customer_id', array(':customer_id' => Yii::app()->user->customerId)); /* render ke view addressbook */ $this->render('addressbook', array('model' => $model)); }