function prepareForm($me) { $vcardform = $this->tpl(); $vcardform->assign('me', $me); $vcardform->assign('desc', trim($me->description)); $vcardform->assign('gender', getGender()); $vcardform->assign('marital', getMarital()); $vcardform->assign('countries', getCountries()); $vcardform->assign('submit', $this->call('ajaxVcardSubmit', "movim_form_to_json('vcard4')")); $vcardform->assign('privacy', $this->call('ajaxChangePrivacy', "this.checked")); // The datepicker arrays $days = $months = $years = array(); for ($i = 1; $i <= 31; $i++) { if ($i < 10) { $j = '0' . $i; } else { $j = (string) $i; } $days[$i] = $j; } for ($i = 1; $i <= 12; $i++) { if ($i < 10) { $j = '0' . $i; } else { $j = (string) $i; } $m = getMonths(); $months[$j] = $m[$i]; } for ($i = date('o'); $i >= 1920; $i--) { array_push($years, $i); } $vcardform->assign('days', $days); $vcardform->assign('months', $months); $vcardform->assign('years', $years); return $vcardform->draw('_vcard4_form', true); }
function ajaxVcardSubmit($vcard) { # Format it ISO 8601: if ($vcard->year->value != -1 && $vcard->month->value != -1 && $vcard->day->value != -1) { $vcard->date->value = $vcard->year->value . '-' . $vcard->month->value . '-' . $vcard->day->value; } unset($vcard->year->value); unset($vcard->month->value); unset($vcard->day->value); $cd = new \Modl\ContactDAO(); $c = $cd->get($this->user->getLogin()); if ($c == null) { $c = new \Modl\Contact(); } $c->jid = $this->user->getLogin(); if (isset($vcard->date->value)) { $c->date = $vcard->date->value; } if (Validator::string()->length(0, 40)->validate($vcard->name->value)) { $c->name = $vcard->name->value; } if (Validator::string()->length(0, 40)->validate($vcard->fn->value)) { $c->fn = $vcard->fn->value; } if (Validator::url()->validate($vcard->url->value)) { $c->url = $vcard->url->value; } if (Validator::in(array_keys(getGender()))->validate($vcard->gender->value)) { $c->gender = $vcard->gender->value; } if (Validator::in(array_keys(getMarital()))->validate($vcard->marital->value)) { $c->marital = $vcard->marital->value; } $c->adrlocality = $vcard->locality->value; $c->adrcountry = $vcard->country->value; if (Validator::email()->validate($vcard->email->value)) { $c->email = $vcard->email->value; } $c->twitter = $vcard->twitter->value; $c->skype = $vcard->skype->value; $c->yahoo = $vcard->yahoo->value; if (Validator::string()->validate($vcard->desc->value)) { $c->description = trim($vcard->desc->value); } $cd = new \Modl\ContactDAO(); $cd->set($c); $r = new Set(); $r->setData($c)->request(); $r = new Moxl\Xec\Action\Vcard\Set(); $r->setData($vcard)->request(); }
function getMarital() { $marital = getMarital(); if ($this->marital != null && $this->marital != 'none') { return $marital[$this->marital]; } }