Error checking in ajax methods.
Localize menu entry.
$value = $_POST['value'];
if(!is_array($value)){
$value = trim($value);
- if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG'))) {
+ if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME'))) {
OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.'))));
exit();
}
$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element);
}
}
+$checksum = md5($vcard->children[$line]->serialize());
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.'))));
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line));
$page = $tmpl->fetchPage();
-OC_JSON::success(array('data' => array( 'page' => $page )));
+OC_JSON::success(array('data' => array( 'checksum' => $checksum, 'page' => $page )));
OC_JSON::checkAppEnabled('contacts');
$id = $_GET['id'];
+$new = isset($_GET['new']) ? true : false;
$vcard = OC_Contacts_App::getContactVCard( $id );
-OC_Contacts_App::renderDetails($id, $vcard);
+OC_Contacts_App::renderDetails($id, $vcard, $new);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
$page = $tmpl->fetchPage();
-OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] )));
+OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'] )));
* @param int $id of contact
* @param Sabre_VObject_Component $vcard to render
*/
- public static function renderDetails($id, $vcard){
+ public static function renderDetails($id, $vcard, $new=false){
$property_types = self::getAddPropertyOptions();
$adr_types = self::getTypesOfProperty('ADR');
$phone_types = self::getTypesOfProperty('TEL');
+ $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
+ $post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+
+ $freeSpace=OC_Filesystem::free_space('/');
+ $freeSpace=max($freeSpace,0);
+ $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
$details = OC_Contacts_VCard::structureContact($vcard);
$name = $details['FN'][0]['value'];
- $tmpl = new OC_Template('contacts','part.details');
+ $t = $new ? 'part.contact' : 'part.details';
+ $tmpl = new OC_Template('contacts',$t);
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
+ $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
+ $tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
$tmpl->assign('property_types',$property_types);
$tmpl->assign('adr_types',$adr_types);
$tmpl->assign('phone_types',$phone_types);
OC_Util::checkAppEnabled('contacts');
$id = $_GET['id'];
-
+if(isset($GET['refresh'])) {
+ header("Cache-Control: no-cache, no-store, must-revalidate");
+}
$l10n = new OC_L10N('contacts');
$card = OC_Contacts_VCard::find( $id );
}
$content = OC_VObject::parse($card['carddata']);
-
+$image = new OC_Image();
// invalid vcard
if( is_null($content)){
- echo $l10n->t('This card is not RFC compatible.');
+ $image->loadFromFile('img/person_large.png');
+ header('Content-Type: '.$image->mimeType());
+ $image();
+ //echo $l10n->t('This card is not RFC compatible.');
exit();
-}
-// Photo :-)
-foreach($content->children as $child){
- if($child->name == 'PHOTO'){
- $mime = 'image/jpeg';
- foreach($child->parameters as $parameter){
- if( $parameter->name == 'TYPE' ){
- $mime = $parameter->value;
+} else {
+ // Photo :-)
+ foreach($content->children as $child){
+ if($child->name == 'PHOTO'){
+ $mime = 'image/jpeg';
+ foreach($child->parameters as $parameter){
+ if( $parameter->name == 'TYPE' ){
+ $mime = $parameter->value;
+ }
+ }
+ if($image->loadFromBase64($child->value)) {
+ header('Content-Type: '.$mime);
+ $image();
+ exit();
+ } else {
+ $image->loadFromFile('img/person_large.png');
+ header('Content-Type: '.$image->mimeType());
+ $image();
}
+ //$photo = base64_decode($child->value);
+ //header('Content-Type: '.$mime);
+ //header('Content-Length: ' . strlen($photo));
+ //echo $photo;
+ //exit();
}
- $photo = base64_decode($child->value);
- header('Content-Type: '.$mime);
- header('Content-Length: ' . strlen($photo));
- echo $photo;
- exit();
}
}
+$image->loadFromFile('img/person_large.png');
+header('Content-Type: '.$image->mimeType());
+$image();
+/*
// Logo :-/
foreach($content->children as $child){
if($child->name == 'PHOTO'){
exit();
}
}
-
+*/
// Not found :-(
-echo $l10n->t('This card does not contain a photo.');
+//echo $l10n->t('This card does not contain a photo.');
</dd>
<dt>
<label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
- </dtl>
+ </dt>
<dd>
<input type="text" id="adr_zipcode" name="value[ADR][5]" value="">
</dd>
}
?>
<tr>
- <td colspan="5">
- <a href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
+ <td colspan="5" style="padding: 0.5em;">
+ <a class="button" href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
</td>
</tr>
<tr>