/**
	 * Add webpage
	 *
	 * @access public
	 * @param void
	 * @return null
	 */
	function add() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$this->setTemplate('add');
		
		$notAllowedMember = '';
		if(!ProjectWebpage::canAdd(logged_user(), active_context(), $notAllowedMember)) {
			if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
			else flash_error(lang('no context permissions to add',lang("webpages"), $notAllowedMember));
			ajx_current("empty");
			return;
		} // if

		$webpage = new ProjectWebpage();

		$webpage_data = array_var($_POST, 'webpage');
		
		if(is_array(array_var($_POST, 'webpage'))) {
			try {
				if(substr_utf($webpage_data['url'],0,7) != 'http://' && substr_utf($webpage_data['url'],0,7) != 'file://' && substr_utf($webpage_data['url'],0,8) != 'https://' && substr_utf($webpage_data['url'],0,6) != 'about:' && substr_utf($webpage_data['url'],0,6) != 'ftp://') {
					$webpage_data['url'] = 'http://' . $webpage_data['url'];
				}
				
				$webpage->setFromAttributes($webpage_data);
				
				DB::beginWork();
				$webpage->save();

				$member_ids = json_decode(array_var($_POST, 'members'));
				
				//link it!
                                $object_controller = new ObjectController();
                                $object_controller->add_subscribers($webpage);
                                $object_controller->add_to_members($webpage, $member_ids);
                                $object_controller->link_to_new_object($webpage);
				$object_controller->add_subscribers($webpage);
                                $object_controller->add_custom_properties($webpage);

				ApplicationLogs::createLog($webpage, ApplicationLogs::ACTION_ADD);
				DB::commit();


				flash_success(lang('success add webpage', $webpage->getObjectName()));
				ajx_current("back");
				// Error...
			} catch(Exception $e) {
				DB::rollback();
				flash_error($e->getMessage());
				ajx_current("empty");
			}

		}

		tpl_assign('webpage', $webpage);
		tpl_assign('webpage_data', $webpage_data);
	} // add
Пример #2
0
	/**
	 * Return the first $len - 3 characters of the comment's text followed by "..."
	 *
	 * @param unknown_type $len
	 */
	function getPreviewText($len = 30) {
		if ($len <= 3) return "...";
		$text = $this->getText();
		if (strlen_utf($text) > $len) {
			return substr_utf($text, 0, $len - 3) . "...";
		} else {
			return $text;
		}
	}
 /**
  * Add webpage
  *
  * @access public
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add');
     if (!ProjectWebpage::canAdd(logged_user(), active_or_personal_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $webpage = new ProjectWebpage();
     $webpage_data = array_var($_POST, 'webpage');
     if (!is_array($webpage_data)) {
         $webpage_data = array('milestone_id' => array_var($_GET, 'milestone_id'));
         // array
     }
     // if
     if (is_array(array_var($_POST, 'webpage'))) {
         try {
             if (substr_utf($webpage_data['url'], 0, 7) != 'http://' && substr_utf($webpage_data['url'], 0, 7) != 'file://' && substr_utf($webpage_data['url'], 0, 8) != 'https://' && substr_utf($webpage_data['url'], 0, 6) != 'about:' && substr_utf($webpage_data['url'], 0, 6) != 'ftp://') {
                 $webpage_data['url'] = 'http://' . $webpage_data['url'];
             }
             $webpage->setFromAttributes($webpage_data);
             $webpage->setIsPrivate(false);
             // Options are reserved only for members of owner company
             if (!logged_user()->isMemberOfOwnerCompany()) {
                 $webpage->setIsPrivate(false);
             }
             // if
             DB::beginWork();
             $webpage->save();
             $webpage->setTagsFromCSV(array_var($webpage_data, 'tags'));
             $object_controller = new ObjectController();
             $object_controller->add_to_workspaces($webpage);
             $object_controller->link_to_new_object($webpage);
             $object_controller->add_subscribers($webpage);
             $object_controller->add_custom_properties($webpage);
             ApplicationLogs::createLog($webpage, $webpage->getWorkspaces(), ApplicationLogs::ACTION_ADD);
             DB::commit();
             flash_success(lang('success add webpage', $webpage->getTitle()));
             ajx_current("back");
             // Error...
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
         // try
     }
     // if
     tpl_assign('webpage', $webpage);
     tpl_assign('webpage_data', $webpage_data);
 }
Пример #4
0
	function build_events_data($ical_events_data, $tz_diff) {
		$result = array();
		
		foreach($ical_events_data as $ical_ev) {
			$data = array();
			$data['name'] = substr_utf(array_var($ical_ev, 'summary', lang("untitle event")), 0, 100);
			$data['description'] = array_var($ical_ev, 'description', '');
			$data['name'] = html_entity_decode($data['name']);
			$data['name'] = str_replace('<br />', "\n", $data['name']);
			$data['description'] = html_entity_decode($data['description']);
			$data['description'] = str_replace('<br />', "\n", $data['description']);
			$data['type_id'] = array_var($ical_ev, 'all_day', 0) == 0 ? 1 : 2;
			
			$data['start'] = date('Y-m-d H:i:s', array_var($ical_ev, 'start_unix') - $tz_diff * 3600);
			$data['duration'] = date('Y-m-d H:i:s', array_var($ical_ev, 'end_unix') - $tz_diff * 3600);

                        $data['repeat_num'] = 0;
			$data['repeat_h'] = 0;
			$data['repeat_d'] = 0;
			$data['repeat_m'] = 0;
			$data['repeat_y'] = 0;
			$data['repeat_forever'] = 0;
			$data['repeat_end'] =  0;
			
			$rrule = array_var($ical_ev, 'rrule', null);
			if ($rrule != null) {
				$data['repeat_end'] = isset($rrule['until_unix']) ? date('Y-m-d', array_var($rrule, 'until_unix')) : 0;
				$data['repeat_num'] = array_var($rrule, 'count', 0);
				$freq = array_var($rrule, 'freq', null);
				$jump = array_var($rrule, 'interval', 1);
				if ($freq != null) {
					switch ($freq) {
						case 'DAILY': $data['repeat_d'] = $jump; break;
						case 'WEEKLY': $data['repeat_d'] = 7 * $jump; break;
						case 'MONTHLY': $data['repeat_m'] = $jump; break;
						case 'YEARLY': $data['repeat_y'] = $jump; break;
					}					
				}
				if ($data['repeat_end'] == 0 && $data['repeat_num'] == 0) $data['repeat_forever'] = 1;
			}
			$data['users_to_invite'] = array();
			$data['users_to_invite'][logged_user()->getId()] = 1; 

			$status = array_var($ical_ev, 'status', 'CONFIRMED');
			switch ($status) {
				case 'CONFIRMED': $data['confirmAttendance'] = 1; break;
				case 'CANCELLED': $data['confirmAttendance'] = 2; break;
				case 'TENTATIVE': $data['confirmAttendance'] = 3; break;
			}
			
			$result[] = $data;
		}
		
		return $result;
	}
 /**
  * Return display name
  *
  * @param boolean $short
  * @return string
  */
 function getDisplayName($short = false)
 {
     $name = $this->getName();
     if ($short) {
         $pieces = explode(' ', $name);
         if (count($pieces) == 2) {
             return $pieces[0] . ' ' . substr_utf($pieces[1], 0, 1) . '.';
         } else {
             return $name;
         }
     } else {
         return $name;
     }
     // if
 }
 function get_conversation_info()
 {
     $email = MailContents::findById(array_var($_GET, 'id'));
     if (!$email instanceof MailContent) {
         flash_error(lang('email dnx'));
         ajx_current("empty");
         return;
     }
     $info = array();
     $mails = MailContents::getMailsFromConversation($email);
     foreach ($mails as $mail) {
         $text = $mail->getBodyPlain();
         if (strlen_utf($text) > 80) {
             $text = substr_utf($text, 0, 80) . "...";
         }
         $state = $mail->getState();
         $show_user_icon = false;
         if ($state == 1 || $state == 3 || $state == 5) {
             if ($mail->getCreatedById() == logged_user()->getId()) {
                 $from = lang('you');
             } else {
                 $from = $mail->getCreatedByDisplayName();
             }
             $show_user_icon = true;
         } else {
             $from = $mail->getFrom();
         }
         $info[] = array('id' => $mail->getId(), 'date' => $mail->getReceivedDate() instanceof DateTimeValue ? $mail->getReceivedDate()->isToday() ? format_time($mail->getReceivedDate()) : format_datetime($mail->getReceivedDate()) : lang('n/a'), 'has_att' => $mail->getHasAttachments(), 'text' => htmlentities($text), 'read' => $mail->getIsRead(logged_user()->getId()), 'from_name' => $state == 1 || $state == 3 || $state == 5 ? lang('you') : $mail->getFromName(), 'from' => $from, 'show_ico' => $show_user_icon);
     }
     tpl_assign('source_email_id', array_var($_GET, 'id'));
     tpl_assign('emails_info', $info);
     $this->setLayout("html");
     $this->setTemplate("llo_email_conversation");
     ajx_current("empty");
 }
Пример #7
0
													$tip_pre = 'end_';
												} else {
													$tip_title = lang('start of task');
													$img_url = image_url('/16x16/task_start.png');
													$tip_pre = 'st_';
												}
												$tip_pre .= gen_id()."_";
												$count++;
												if ($count <= $max_events_to_show){
													$color = 'B1BFAC'; 
													$subject = clean($task->getObjectName()).'- <span class="italic">'.lang('task').'</span>';
													$cal_text = clean($task->getObjectName());
													
													$tip_text = str_replace("\r", '', lang('assigned to') .': '. clean($task->getAssignedToName()) . (trim($task->getText()) == '' ? '' : '<br><br>'. $task->getText()));
													$tip_text = purify_html(str_replace("\n", '<br>', $tip_text));													
													if (strlen_utf($tip_text) > 200) $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
								?>
													<div id="m_ta_div_<?php echo $tip_pre.$task->getId()?>" class="<?php echo "og-wsname-color-$ws_color" ?>" style="height:20px;margin: 1px;padding-left:1px;padding-bottom:0px;border-radius:4px;border: 1px solid;border-color:<?php echo $border_color ?>;<?php echo $extra_style ?>">
														<a href='<?php echo $task->getViewUrl()?>' class='internalLink nobr' onclick="og.disableEventPropagation(event);return true;"  style="border-width:0px">
															<img src="<?php echo $img_url ?>" style="vertical-align: middle;">
														 	<span><?php echo $cal_text ?></span>
														</a>
													</div>
													<script>
														addTip('m_ta_div_<?php echo $tip_pre.$task->getId() ?>', '<span class="italic">' + '<?php echo $tip_title ?>' + '</span> - ' + <?php echo json_encode(clean($task->getTitle()))?>, <?php echo json_encode(trim($tip_text) != '' ? trim($tip_text) : '');?>);
														<?php if (!logged_user()->isGuest()) { ?>
														og.createMonthlyViewDrag('m_ta_div_<?php echo $tip_pre.$task->getId() ?>', '<?php echo $task->getId()?>', false, 'task'); // Drag
														<?php } ?>
													</script>
								<?php
												}//if count
Пример #8
0
 /**
  * Return object name
  *
  * @param void
  * @return string
  */
 function getObjectName()
 {
     $object = $this->getObject();
     return $object instanceof ProjectDataObject ? lang('comment on object', substr_utf($this->getText(), 0, 50) . '...', $object->getObjectName()) : $this->getObjectTypeName();
 }
Пример #9
0
/**
 * This function will return true if $str is valid function name (made out of alpha numeric characters + underscore)
 *
 * @param string $str
 * @return boolean
 */
function is_valid_function_name($str)
{
    $check_str = trim($str);
    if ($check_str == '') {
        return false;
    }
    // empty string
    $first_char = substr_utf($check_str, 0, 1);
    if (is_numeric($first_char)) {
        return false;
    }
    // first char can't be number
    return (bool) preg_match("/^([a-zA-Z0-9_]*)\$/", $check_str);
}
Пример #10
0
                                }
                            }
                            $count++;
                            if ($count <= 3) {
                                $cal_text = clean($task->getTitle());
                                $cal_text = mb_strlen($cal_text) < $to_show_len ? $cal_text : mb_substr($cal_text, 0, $to_show_len - 3) . "...";
                                $output .= '<div class="event_block">';
                                $output .= "<span id='o_ta_div_{$tip_pre}" . $task->getId() . "'>";
                                $output .= "<a class=\"internalLink link-ico {$ico}\" style='vertical-align:bottom;' href='" . $task->getViewUrl() . "' onclick=\"og.disableEventPropagation(event);\" >";
                                $output .= $cal_text . "</a>";
                                $output .= '</span>';
                                $output .= "</div>";
                                $tip_text = str_replace("\r", '', lang('assigned to') . ': ' . clean($task->getAssignedToName()) . (trim(clean($task->getText())) == '' ? '' : '<br><br>' . clean($task->getText())));
                                $tip_text = str_replace("\n", '<br>', $tip_text);
                                if (strlen_utf($tip_text) > 200) {
                                    $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
                                }
                                ?>
									<script>
										addTip('o_ta_div_<?php 
                                echo $tip_pre;
                                ?>
' + <?php 
                                echo $task->getId();
                                ?>
, '<i>' + '<?php 
                                echo $tip_title;
                                ?>
' + '</i> - ' + <?php 
                                echo json_encode(clean($task->getTitle()));
                                ?>
Пример #11
0
 function createMinimumUser($email, $compId)
 {
     $contact = Contacts::getByEmail($email);
     $posArr = strpos_utf($email, '@') === FALSE ? null : strpos($email, '@');
     $user_data = array('username' => $email, 'display_name' => $posArr != null ? substr_utf($email, 0, $posArr) : $email, 'email' => $email, 'contact_id' => isset($contact) ? $contact->getId() : null, 'password_generator' => 'random', 'timezone' => isset($contact) ? $contact->getTimezone() : 0, 'create_contact' => !isset($contact), 'company_id' => $compId, 'send_email_notification' => true);
     // array
     $user = null;
     $user = create_user($user_data, false, '');
     return $user;
 }
Пример #12
0
				} else {
					$datetime = format_datetime($object->getArchivedOn(), $date_format, logged_user()->getTimezone());
					echo lang('user date', $archive_user->getCardUserUrl(), $username, $datetime, clean($archive_user->getObjectName()));
				}
			}
			 ?></div>
		<?php } // if ?>
		
		<?php
		if ($object instanceof ProjectFile && $object->getLastRevision() instanceof ProjectFileRevision) { ?>
			<span style="color:#333333;font-weight:bolder;">
    			<?php echo lang('mime type') ?>:
    			<?php $mime = $object->getLastRevision()->getTypeString(); ?>
			</span><br/><div style="padding-left:10px" title="<?php echo  $mime ?>">
				<?php if (strlen($mime) > 30) {
					echo substr_utf($mime, 0, 15) . '&hellip;' . substr_utf($mime, -15);
				} else {
					echo $object->getLastRevision()->getTypeString();
				}?>
			</div>
		<?php if ($object->isCheckedOut()) { ?>
	    		<span style="color:#333333;font-weight:bolder;">
	    			<?php echo lang('checked out by') ?>:
				</span><br/><div style="padding-left:10px">
				<?php
				$checkout_user = Contacts::findById($object->getCheckedOutById());
				if ($checkout_user instanceof Contact && $checkout_user->isUser()){
					if (logged_user()->getId() == $checkout_user->getId())
						$username = lang('you');
					else
						$username = clean($checkout_user->getObjectName());
Пример #13
0
if ($show_help_option == 'always' || ($show_help_option == 'until_close' && user_config_option('show_active_tasks_widget_context_help', true, logged_user()->getId()))) { 
	render_context_help($this, 'chelp active tasks widget', 'active_tasks_widget');
} ?>

<div style="padding:10px">
<table id="dashTableTIP" style="width:100%;">
<?php
$c = 0;
foreach ($tasks_in_progress as $task) {
	$stCount = $task->countAllSubTasks();
	$c++;
	$text = $task->getText();
	if ($text != '')
		$text = ": " . $text;
	if(strlen_utf($text)>100)
		$text = substr_utf($text,0,100) . " ...";
	$text = clean($text);
	?>
		<tr class="<?php echo $c % 2 == 1? '':'dashAltRow'?>"><td><div class="db-ico ico-task">&nbsp;></div></td><td style="padding-left:5px;padding-bottom:2px">
	<?php $dws = $task->getWorkspaces(logged_user()->getWorkspacesQuery());
	$projectLinks = array();
	foreach ($dws as $ws) {
		$projectLinks[] = $ws->getId();
	}
	echo '<span class="project-replace">' . implode(',',$projectLinks) . '</span>';?>
	<a class='internalLink' href='<?php echo $task->getViewUrl() ?>'><?php echo clean($task->getTitle())?><?php echo $text ?></a></td>
	<?php /*<td align="right"><?php $timeslot = Timeslots::getOpenTimeslotByObject($task,logged_user());
		if ($timeslot) { 
			if (!$timeslot->isPaused()) {?>
			<div id="<?php echo $genid . $task->getId() ?>timespan"></div>
			<script>
Пример #14
0
         $read_style = "";
         if (!$info->getIsRead(logged_user()->getId())) {
             $read_style = "font-weight: bold;";
             $unread++;
         }
         $conversation_block .= '<td style="width:20px;' . $read_style . '">';
         if ($info->getHasAttachments()) {
             $conversation_block .= '<div class="db-ico ico-attachment"></div>';
         }
         $conversation_block .= '<td style="width:20px;' . $read_style . '">';
         if ($show_user_icon) {
             $conversation_block .= '<div class="db-ico ico-user"></div>';
         }
         $info_text = $info->getTextBody();
         if (strlen_utf($info_text) > 90) {
             $info_text = substr_utf($info_text, 0, 90) . "...";
         }
         $view_url = get_url('mail', 'view', array('id' => $info->getId(), 'replace' => 1));
         $conversation_block .= '<td>';
         $conversation_block .= '	<a style="' . $read_style . '" class="internalLink" href="' . $view_url . '" onclick="og.openLink(\'' . $view_url . '\');return false;" title="' . $info->getFrom() . '">';
         $conversation_block .= $from;
         if (!$is_current) {
             $conversation_block .= '	</a><span class="desc">- ' . $info_text . '</span></td>';
         }
         $info_date = $info->getReceivedDate() instanceof DateTimeValue ? $info->getReceivedDate()->isToday() ? format_time($info->getReceivedDate()) : format_datetime($info->getReceivedDate()) : lang('n/a');
         $conversation_block .= '</td><td style="text-align:right;padding-right:3px"><span class="desc">' . lang('date') . ': </span>' . $info_date . '</td>';
     }
     //foreach
     $conversation_block .= '</table>';
     $conversation_block .= '</div>';
 } else {
 /**
  * Prepare SQL (replace ? with data from $arguments array)
  *
  * @param string $sql SQL that need to be prepared
  * @param array $arguments Array of SQL arguments...
  * @return string
  */
 function prepareSQL($sql, $arguments = null)
 {
     if (is_foreachable($arguments)) {
         $offset = 0;
         foreach ($arguments as $argument) {
             $question_mark_pos = strpos_utf($sql, '?', $offset);
             if ($question_mark_pos !== false) {
                 $escaped = $this->escapeString($argument);
                 $escaped_len = strlen_utf($escaped);
                 $sql = substr_utf($sql, 0, $question_mark_pos) . $escaped . substr_utf($sql, $question_mark_pos + 1, strlen_utf($sql));
                 $offset = $question_mark_pos + $escaped_len;
             }
             // if
         }
         // foreach
     }
     // if
     return $sql;
 }
Пример #16
0
											}
											
											$pre_tf = $real_start->getDay() == $real_duration->getDay() ? '' : 'D j, ';
											$ev_hour_text = (!$event->isRepetitive() && $real_start->getDay() != $event_start->getDay()) ? "... ".format_date($real_duration, $timeformat, 0) : format_date($real_start, $timeformat, 0);
											
											$assigned = "";
											if ($event instanceof ProjectTask && $event->getAssignedToContactId() > 0) {
												$assigned = "<br>" . lang('assigned to') .': '. $event->getAssignedToName();
												$task_desc = purify_html($event->getText());
												$tipBody = lang('assigned to') .': '. clean($event->getAssignedToName()) . (trim(clean($event->getText())) != '' ? '<br><br>' . trim($task_desc) : '');
											} else {
												$tipBody = format_date($real_start, $pre_tf.$timeformat, 0) .' - '. format_date($real_duration, $pre_tf.$timeformat, 0) . $assigned . (trim(clean($event->getDescription())) != '' ? '<br><br>' . clean($event->getDescription()) : '');
												$tipBody = str_replace("\r", '', $tipBody);
												$tipBody = str_replace("\n", '<br>', $tipBody);
											}
											if (strlen_utf($tipBody) > 200) $tipBody = substr_utf($tipBody, 0, strpos($tipBody, ' ', 200)) . ' ...';
											
											$ev_duration = DateTimeValueLib::get_time_difference($event_start->getTimestamp(), $event_duration->getTimestamp());
											$id_suffix = "_$day_of_week"; 
?>
											<script>
												if (<?php echo $top; ?> < scroll_to || scroll_to == -1) {
													scroll_to = <?php echo $top;?>;
												}
												addTip('w_ev_div_' + '<?php echo $event->getId() . $id_suffix ?>', <?php echo json_encode(clean($event->getObjectName())) ?>, <?php echo json_encode($tipBody);?>);
											</script>
<?php
											$bold = "bold";
											if ($event instanceof Contact || $event->getIsRead(logged_user()->getId())){
												$bold = "normal";
											}
Пример #17
0
        echo $object->getId();
        ?>
"></span>
			    		<script>
							var crumbHtml = <?php 
        echo $crumbJs;
        ?>
;
							$("#object_crumb_<?php 
        echo $object->getId();
        ?>
").html(crumbHtml);
						</script>
						<?php 
        if ($object instanceof ProjectTask) {
            $text = strlen_utf($object->getText()) > 100 ? substr_utf(html_to_text($object->getText()), 0, 100) . "..." : strip_tags($object->getText());
            $text = remove_scripts($text);
            if (strlen_utf($text) > 0) {
                ?>
&nbsp;-&nbsp;<span class="desc nobr"><?php 
                echo $text;
                ?>
</span>
							<?php 
            }
            ?>
						<?php 
        }
        ?>
					</div>
				</td>
Пример #18
0
 /**
  * Return display name (first name and last name)
  *
  * @param boolean $short
  * @return string
  */
 function getDisplayName($short = false)
 {
     if ($this->display_name === false) {
         if ($this->getFirstName() && $this->getLastName()) {
             if ($short) {
                 return $this->getFirstName() . ' ' . substr_utf($this->getLastName(), 0, 1) . '.';
             }
             // if
             $this->display_name = $this->getFirstName() . ' ' . $this->getLastName();
         } elseif ($this->getFirstName()) {
             $this->display_name = $this->getFirstName();
         } elseif ($this->getLastName()) {
             $this->display_name = $this->getLastName();
         } else {
             $this->display_name = $this->getEmail();
         }
         // if
     }
     // if
     return $this->display_name;
 }
 /**
  * Prepares return object for a list of emails and messages
  *
  * @param array $totMsg
  * @param integer $start
  * @param integer $limit
  * @return array
  */
 private function prepareObject($totMsg, $start, $limit, $total)
 {
     $object = array("totalCount" => $total, "start" => $start, "messages" => array());
     $custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(ProjectMessages::instance()->getObjectTypeId());
     $ids = array();
     for ($i = 0; $i < $limit; $i++) {
         if (isset($totMsg[$i])) {
             $msg = $totMsg[$i];
             if ($msg instanceof ProjectMessage) {
                 $text = $msg->getText();
                 if (strlen($text) > 100) {
                     $text = substr_utf($text, 0, 100) . "...";
                 }
                 $object["messages"][$i] = array("id" => $i, "ix" => $i, "object_id" => $msg->getId(), "ot_id" => $msg->getObjectTypeId(), "type" => $msg->getObjectTypeName(), "name" => $msg->getObjectName(), "text" => html_to_text($text), "date" => $msg->getUpdatedOn() instanceof DateTimeValue ? $msg->getUpdatedOn()->isToday() ? format_time($msg->getUpdatedOn()) : format_datetime($msg->getUpdatedOn()) : '', "is_today" => $msg->getUpdatedOn() instanceof DateTimeValue ? $msg->getUpdatedOn()->isToday() : 0, "userId" => $msg->getCreatedById(), "userName" => $msg->getCreatedByDisplayName(), "updaterId" => $msg->getUpdatedById() ? $msg->getUpdatedById() : $msg->getCreatedById(), "updaterName" => $msg->getUpdatedById() ? $msg->getUpdatedByDisplayName() : $msg->getCreatedByDisplayName(), "memPath" => json_encode($msg->getMembersIdsToDisplayPath()));
                 $ids[] = $msg->getId();
                 foreach ($custom_properties as $cp) {
                     $object["messages"][$i]['cp_' . $cp->getId()] = get_custom_property_value_for_listing($cp, $msg);
                 }
             }
         }
     }
     $read_objects = ReadObjects::getReadByObjectList($ids, logged_user()->getId());
     foreach ($object["messages"] as &$data) {
         $data['isRead'] = isset($read_objects[$data['object_id']]);
     }
     return $object;
 }
 /**
  * Prepares return object for a list of emails and messages
  *
  * @param array $totMsg
  * @param integer $start
  * @param integer $limit
  * @return array
  */
 private function prepareObject($totMsg, $start, $limit, $total)
 {
     $object = array("totalCount" => $total, "start" => $start, "messages" => array());
     for ($i = 0; $i < $limit; $i++) {
         if (isset($totMsg[$i])) {
             $msg = $totMsg[$i];
             if ($msg instanceof ProjectMessage) {
                 $text = $msg->getText();
                 if (strlen($text) > 100) {
                     $text = substr_utf($text, 0, 100) . "...";
                 }
                 $object["messages"][] = array("id" => $i, "ix" => $i, "object_id" => $msg->getId(), "type" => 'message', "title" => $msg->getTitle(), "text" => $text, "date" => $msg->getUpdatedOn() instanceof DateTimeValue ? $msg->getUpdatedOn()->isToday() ? format_time($msg->getUpdatedOn()) : format_datetime($msg->getUpdatedOn()) : '', "is_today" => $msg->getUpdatedOn() instanceof DateTimeValue ? $msg->getUpdatedOn()->isToday() : 0, "wsIds" => $msg->getUserWorkspacesIdsCSV(logged_user()), "userId" => $msg->getCreatedById(), "userName" => $msg->getCreatedByDisplayName(), "updaterId" => $msg->getUpdatedById() ? $msg->getUpdatedById() : $msg->getCreatedById(), "updaterName" => $msg->getUpdatedById() ? $msg->getUpdatedByDisplayName() : $msg->getCreatedByDisplayName(), "tags" => project_object_tags($msg), "isRead" => $msg->getIsRead(logged_user()->getId()));
             }
         }
     }
     return $object;
 }
Пример #21
0
function safe_name($text, $use_visual_mode = false)
{
    if (!$text) {
        return '';
    }
    $text = strtolower_utf($text);
    $translation_table = array('ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'ō' => 'o', 'š' => 's', 'ū' => 'u', 'ž' => 'z', 'а' => 'a', 'б' => 'b', 'в' => $use_visual_mode ? 'b' : 'v', 'г' => 'g', 'д' => $use_visual_mode ? 'g' : 'd', 'е' => 'e', 'ё' => 'e', 'ж' => 'z', 'з' => $use_visual_mode ? '3' : 'z', 'и' => $use_visual_mode ? 'u' : 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => $use_visual_mode ? 'h' : 'n', 'о' => 'o', 'п' => 'p', 'р' => $use_visual_mode ? 'p' : 'r', 'с' => $use_visual_mode ? 'c' : 's', 'т' => 't', 'у' => $use_visual_mode ? 'y' : 'u', 'ф' => 'f', 'х' => $use_visual_mode ? 'x' : 'h', 'ц' => 'c', 'ч' => 'c', 'ш' => 's', 'щ' => 's', 'ъ' => '', 'ы' => 'i', 'ь' => '', 'э' => 'e', 'ю' => 'u', 'я' => 'j', 'ґ' => 'g', 'і' => 'i', 'ї' => 'i', 'є' => 'e');
    $text = strtr($text, $translation_table);
    $allowed_chars = 'abcdefghijklmnopqrstuvwxyz01234567890_';
    $out = '';
    for ($i = 0; $i < strlen_utf($text); $i++) {
        $char = substr_utf($text, $i, 1);
        if (strlen($char) != 1) {
            $out .= '_';
        } else {
            if (strpos($allowed_chars, $char) !== FALSE) {
                $out .= $char;
            } else {
                $out .= '_';
            }
        }
    }
    $out = trim($out, '_');
    $out = preg_replace('/__+/u', '_', $out);
    $out = preg_replace('/--+/u', '-', $out);
    if ($out == '') {
        $out = '_';
    }
    return $out;
}
Пример #22
0
 /**
  * Return paged project files
  *
  * @param Project $project
  * @param ProjectFolder $folder
  * @param boolean $hide_private Don't show private files
  * @param string $order Order files by name or by posttime (desc)
  * @param integer $page Current page
  * @param integer $files_per_page Number of files that will be showed per single page
  * @param boolean $group_by_order Group files by order field
  * @return array
  */
 static function getProjectFiles(Project $project, $folder = null, $hide_private = false, $order = null, $page = null, $files_per_page = null, $group_by_order = false)
 {
     trace(__FILE__, 'getProjectFiles()');
     if ($order == self::ORDER_BY_POSTTIME) {
         $order_by = '`created_on` DESC';
     } else {
         $order_by = '`filename`';
     }
     // if
     // #PAGE# is reserved as a placeholder
     //if (!($page == '#PAGE#')) {
     if ((int) $page < 1) {
         $page = 1;
     }
     if ((int) $files_per_page < 1) {
         $files_per_page = 10;
     }
     //} // if
     $folder_ids = array();
     if ($folder instanceof ProjectFolder && $folder->getProjectId() == $project->getId()) {
         if ($hide_private) {
             $conditions = array('`project_id` = ? AND `folder_id` = ? AND `is_private` = ? AND `is_visible` = ?', $project->getId(), $folder->getId(), false, true);
         } else {
             $conditions = array('`project_id` = ? AND `folder_id` = ? AND `is_visible` = ?', $project->getId(), $folder->getId(), true);
         }
         // if
     } else {
         if ($hide_private) {
             $conditions = array('`project_id` = ? AND `is_private` = ? AND `is_visible` = ?', $project->getId(), false, true);
         } else {
             $conditions = array('`project_id` = ? AND `is_visible` = ?', $project->getId(), true);
         }
         // if
     }
     // if
     list($files, $pagination) = ProjectFiles::paginate(array('conditions' => $conditions, 'order' => $order_by), $files_per_page, $page);
     if ($group_by_order) {
         $grouped_files = array();
         if (is_array($files) && count($files)) {
             $today = DateTimeValueLib::now();
             foreach ($files as $file) {
                 $group_by_str = '';
                 if ($order == self::ORDER_BY_POSTTIME) {
                     $created_on = $file->getCreatedOn();
                     if ($created_on->getYear() == $today->getYear()) {
                         $group_by_str = format_descriptive_date($created_on);
                     } else {
                         $group_by_str = format_date($created_on);
                     }
                     // if
                 } else {
                     $group_by_str = strtoupper(substr_utf($file->getFilename(), 0, 1));
                 }
                 // if
                 if (!isset($grouped_files[$group_by_str]) || !is_array($grouped_files[$group_by_str])) {
                     $grouped_files[$group_by_str] = array();
                 }
                 $grouped_files[$group_by_str][] = $file;
             }
             // foreach
         }
         // if
         $files = is_array($grouped_files) ? $grouped_files : null;
     }
     // if
     return array($files, $pagination);
 }
Пример #23
0
 /**
  * Returns datetime as a formatted string, depending on localization.
  * Month and Day descriptions are taken from language definitions.
  *
  * @param string $format Same format as function date(...)
  * @param int $timestamp
  * @return string
  */
 function dateByLocalization($format, $timestamp, $timezone = 0)
 {
     if ($timestamp == 0) {
         $timestamp = time();
     }
     $timestamp += $timezone * 3600;
     $names['l'] = array(-1 => 'w', 0 => lang('sunday'), 1 => lang('monday'), 2 => lang('tuesday'), 3 => lang('wednesday'), 4 => lang('thursday'), 5 => lang('friday'), 6 => lang('saturday'), 7 => lang('sunday'));
     $names['D'] = array(-1 => 'w', 0 => lang('sunday short'), 1 => lang('monday short'), 2 => lang('tuesday short'), 3 => lang('wednesday short'), 4 => lang('thursday short'), 5 => lang('friday short'), 6 => lang('saturday short'), 7 => lang('sunday short'));
     $names['F'] = array(-1 => 'n', 1 => lang('month 1'), 2 => lang('month 2'), 3 => lang('month 3'), 4 => lang('month 4'), 5 => lang('month 5'), 6 => lang('month 6'), 7 => lang('month 7'), 8 => lang('month 8'), 9 => lang('month 9'), 10 => lang('month 10'), 11 => lang('month 11'), 12 => lang('month 12'));
     $names['M'] = array(-1 => 'n');
     for ($i = 1; $i <= 12; $i++) {
         $names['M'][$i] = substr_utf($names['F'][$i], 0, 3);
     }
     $str_date = '';
     $i = 0;
     while (strpos($format, 'l', $i) !== FALSE || strpos($format, 'D', $i) !== FALSE || strpos($format, 'F', $i) !== FALSE || strpos($format, 'M', $i) !== FALSE) {
         $ch['l'] = strpos($format, 'l', $i);
         $ch['D'] = strpos($format, 'D', $i);
         $ch['F'] = strpos($format, 'F', $i);
         $ch['M'] = strpos($format, 'M', $i);
         foreach ($ch as $k => $v) {
             if ($v === FALSE) {
                 unset($ch[$k]);
             }
         }
         $a = min($ch);
         $str_date .= date(substr($format, $i, $a - $i), $timestamp) . $names[$format[$a]][date($names[$format[$a]][-1], $timestamp)];
         $i = $a + 1;
     }
     $str_date .= date(substr($format, $i), $timestamp);
     return $str_date;
 }
Пример #24
0
 /**
  * Edit comment
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->setTemplate('add_comment');
     $comment = Comments::findById(get_id());
     if (!$comment instanceof Comment) {
         flash_error(lang('comment dnx'));
         ajx_current("empty");
         return;
     }
     $object = $comment->getRelObject();
     if (!$object instanceof ContentDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     if (trim($comment->getViewUrl())) {
         $redirect_to = $comment->getViewUrl();
     } elseif (trim($object->getObjectUrl())) {
         $redirect_to = $object->getObjectUrl();
     }
     if (!$comment->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $comment_data = array_var($_POST, 'comment');
     if (!is_array($comment_data)) {
         $comment_data = array('text' => $comment->getText());
     }
     tpl_assign('comment_form_object', $object);
     tpl_assign('comment', $comment);
     tpl_assign('comment_data', $comment_data);
     if (is_array(array_var($_POST, 'comment'))) {
         try {
             $comment->setFromAttributes($comment_data);
             $comment->setRelObjectId($object->getId());
             $comment->setObjectName(substr_utf($comment->getText(), 0, 250));
             DB::beginWork();
             $comment->save();
             ApplicationLogs::createLog($comment, ApplicationLogs::ACTION_EDIT);
             $object->onEditComment($comment);
             DB::commit();
             flash_success(lang('success edit comment'));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             ajx_current("empty");
             flash_error($e->getMessage());
         }
         // try
     }
     // if
 }
Пример #25
0
	function import_from_vcard() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		@set_time_limit(0);
		ini_set('auto_detect_line_endings', '1');
		if (isset($_GET['from_menu']) && $_GET['from_menu'] == 1) unset($_SESSION['go_back']);
		if (isset($_SESSION['go_back'])) {
			unset($_SESSION['go_back']);
			ajx_current("start");
		} else {
                
                    if(!Contact::canAdd(logged_user(), active_context())) {
                            flash_error(lang('no access permissions'));
                            ajx_current("empty");
                            return;
                    } 

                    $this->setTemplate('vcard_import');
                    tpl_assign('import_type', 'contact');                

                    $filedata = array_var($_FILES, 'vcard_file');
                    if (is_array($filedata)) {
                            $filename = ROOT.'/tmp/'.logged_user()->getId().'temp.vcf';
                            copy($filedata['tmp_name'], $filename);
                            $result = $this->read_vcard_file($filename);
                            unlink($filename);
                            $import_result = array('import_ok' => array(), 'import_fail' => array());

                            foreach ($result as $contact_data) {
                                    try {
                                            DB::beginWork();
                                            if (isset($contact_data['photo_tmp_filename'])) {
                                                $file_id = FileRepository::addFile($contact_data['photo_tmp_filename'], array('public' => true));
                                                $contact_data['picture_file'] = $file_id;
                                                unlink($contact_data['photo_tmp_filename']);
                                                unset($contact_data['photo_tmp_filename']);
                                            }
                                            if (isset($contact_data['company_name'])) {
                                                $company = Contacts::findOne(array("conditions" => "`first_name` = '".mysql_real_escape_string($contact_data['company_name'])."'"));
                                                if ($company == null) {                                                        
                                                        $company = new Contact();
                                                        $company->setObjectName($contact_data['company_name']);
                                                        $company->setIsCompany(1);
                                                        $company->save();                                                        
                                                        ApplicationLogs::createLog($company, null, ApplicationLogs::ACTION_ADD);
                                                }
                                                $contact_data['company_id'] = $company->getObjectId();
                                                unset($contact_data['company_name']);
                                            }

                                            $contact_data['import_status'] = '('.lang('updated').')';
                                            $fname = DB::escape(array_var($contact_data, "first_name"));
                                            $lname = DB::escape(array_var($contact_data, "surname"));
                                            $email_cond = array_var($contact_data, "email") != '' ? " OR email_address = '".array_var($contact_data, "email")."'" : "";
                                            $contact = Contacts::findOne(array(
                                                "conditions" => "first_name = ".$fname." AND surname = ".$lname." $email_cond",
                                                'join' => array(
                                                        'table' => ContactEmails::instance()->getTableName(),
                                                        'jt_field' => 'contact_id',
                                                        'e_field' => 'object_id',
                                                )));                                                        
                                            $log_action = ApplicationLogs::ACTION_EDIT;
                                            if (!$contact) {
                                                    $contact = new Contact();
                                                    $contact_data['import_status'] = '('.lang('new').')';
                                                    $log_action = ApplicationLogs::ACTION_ADD;
                                                    $can_import = active_project() != null ? $contact->canAdd(logged_user(), active_project()) : can_manage_contacts(logged_user());
                                            } else {
                                                    $can_import = $contact->canEdit(logged_user());
                                            }

                                            if ($can_import) {
                                                    $comp_name = DB::escape(array_var($contact_data, "company_id"));
                                                    if ($comp_name != '') {
                                                            $company = Contacts::findOne(array("conditions" => "first_name = $comp_name AND is_company = 1"));
                                                            if ($company) {
                                                                    $contact_data['company_id'] = $company->getId();
                                                            } 
                                                            $contact_data['import_status'] .= " " . lang("company") . " $comp_name";
                                                    } else {
                                                            $contact_data['company_id'] = 0;
                                                    }
                                                    $contact_data['birthday'] = $contact_data["o_birthday"];
                                                    $contact_data['name'] = $contact_data['first_name']." ".$contact_data['surname'];
                                                    $contact->setFromAttributes($contact_data);
                                                    $contact->save();

                                                    //Home form
                                                    if($contact_data['h_address'] != "")
                                                        $contact->addAddress($contact_data['h_address'], $contact_data['h_city'], $contact_data['h_state'], $contact_data['h_country'], $contact_data['h_zipcode'], 'home');
                                                    if($contact_data['h_phone_number'] != "") $contact->addPhone($contact_data['h_phone_number'], 'home', true);
                                                    if($contact_data['h_phone_number2'] != "") $contact->addPhone($contact_data['h_phone_number2'], 'home');
                                                    if($contact_data['h_mobile_number'] != "") $contact->addPhone($contact_data['h_mobile_number'], 'mobile');
                                                    if($contact_data['h_fax_number'] != "") $contact->addPhone($contact_data['h_fax_number'], 'fax');
                                                    if($contact_data['h_pager_number'] != "") $contact->addPhone($contact_data['h_pager_number'], 'pager');
                                                    if($contact_data['h_web_page'] != "") $contact->addWebpage($contact_data['h_web_page'], 'personal');

                                                    //Work form
                                                    if($contact_data['w_address'] != "")
                                                        $contact->addAddress($contact_data['w_address'], $contact_data['w_city'], $contact_data['w_state'], $contact_data['w_country'], $contact_data['w_zipcode'], 'work');
                                                    if($contact_data['w_phone_number'] != "") $contact->addPhone($contact_data['w_phone_number'], 'work', true);
                                                    if($contact_data['w_phone_number2'] != "") $contact->addPhone($contact_data['w_phone_number2'], 'work');
                                                    if($contact_data['w_assistant_number'] != "") $contact->addPhone($contact_data['w_assistant_number'], 'assistant');
                                                    if($contact_data['w_callback_number'] != "") $contact->addPhone($contact_data['w_callback_number'], 'callback');
                                                    if($contact_data['w_fax_number'] != "") $contact->addPhone($contact_data['w_fax_number'], 'fax', true);
                                                    if($contact_data['w_web_page'] != "") $contact->addWebpage($contact_data['w_web_page'], 'work');

                                                    //Other form
                                                    if($contact_data['o_address'] != "")
                                                        $contact->addAddress($contact_data['o_address'], $contact_data['o_city'], $contact_data['o_state'], $contact_data['o_country'], $contact_data['o_zipcode'], 'other');
                                                    if($contact_data['o_phone_number'] != "") $contact->addPhone($contact_data['o_phone_number'], 'other', true);
                                                    if($contact_data['o_phone_number2'] != "") $contact->addPhone($contact_data['o_phone_number2'], 'other');
                                                    if($contact_data['o_web_page'] != "") $contact->addWebpage($contact_data['o_web_page'], 'other');

                                                    //Emails and instant messaging form
                                                    if($contact_data['email'] != "") $contact->addEmail($contact_data['email'], 'personal', true);
                                                    if($contact_data['email2'] != "") $contact->addEmail($contact_data['email2'], 'personal');
                                                    if($contact_data['email3'] != "") $contact->addEmail($contact_data['email3'], 'personal');

                                                    ApplicationLogs::createLog($contact, null, $log_action);
                                                    $import_result['import_ok'][] = $contact_data;
                                            } else {
                                                    throw new Exception(lang('no access permissions'));
                                            }
                                            DB::commit();					
                                    } catch (Exception $e) {
                                            DB::rollback();
                                            $fail_msg = substr_utf($e->getMessage(), strpos_utf($e->getMessage(), "\r\n"));
                                            $import_result['import_fail'][] = array('first_name' => $fname, 'surname' => $lname, 'email' => $contact_data['email'], 'import_status' => $contact_data['import_status'], 'fail_message' => $fail_msg);
                                    }
                            }
                            $_SESSION['go_back'] = true;
                            tpl_assign('import_result', $import_result);
                        }
                    }
                        
	}
Пример #26
0
 /**
  * Return shortened description
  *
  * @access public
  * @param void
  * @return string
  */
 function getShortDescription()
 {
     $return = substr_utf($this->getDescription(), 0, 50);
     return strlen_utf($this->getDescription()) > 50 ? $return . '...' : $return;
 }
Пример #27
0
                $real_duration = $event_duration;
            }
        }
    }
    $pre_tf = $real_start->getDay() == $real_duration->getDay() ? '' : 'D j, ';
    $ev_hour_text = format_date($real_start, $pre_tf . $timeformat, 0) . " - " . format_date($real_duration, $pre_tf . $timeformat, 0);
    $assigned = "";
    if ($event instanceof ProjectTask && $event->getAssignedToContactId() > 0) {
        $assigned = "<br>" . lang('assigned to') . ': ' . $event->getAssignedToName();
        $tipBody = purify_html($event->getText());
    } else {
        $tipBody = $ev_hour_text . $assigned . (trim(clean($event->getDescription())) != '' ? '<br><br>' . clean($event->getDescription()) : '');
        $tipBody = str_replace(array("\r", "\n"), array(' ', '<br>'), $tipBody);
    }
    if (strlen_utf($tipBody) > 200) {
        $tipBody = substr_utf($tipBody, 0, strpos($tipBody, ' ', 200)) . ' ...';
    }
    ?>
												<script>
													if (<?php 
    echo $top;
    ?>
 < scroll_to || scroll_to == -1) {
														scroll_to = <?php 
    echo $top;
    ?>
;
													}
													addTip('d_ev_div_' + <?php 
    echo $event->getId();
    ?>
Пример #28
0
 /**
  * Return object name
  *
  * @access public
  * @param void
  * @return string
  */
 function getObjectName()
 {
     $return = substr_utf($this->getText(), 0, 50);
     return strlen_utf($this->getText()) > 50 ? $return . '...' : $return;
 }
Пример #29
0
				if (!$info->getIsRead(logged_user()->getId()) ) {
					$read_style = "font-weight: bold;";
					$unread++;
				}
				
				$conversation_block .= '<td style="width:20px;'.$read_style.'">';
				if ($info->getHasAttachments()) { 
					$conversation_block .= '<div class="db-ico ico-attachment"></div>';
				}
				$conversation_block .= '<td style="width:20px;'.$read_style.'">';
				if ($show_user_icon) { 
					$conversation_block .= '<div class="db-ico ico-user"></div>';
				}
				
				$info_text = $info->getTextBody();
				if (strlen_utf($info_text) > 90) $info_text = substr_utf($info_text, 0, 90) . "...";		
				
				$view_url = get_url('mail', 'view', array('id' => $info->getId(), 'replace' => 1));
				$conversation_block .= '<td>';
				$conversation_block .= '	<a style="'.$read_style.'" class="internalLink" href="'.$view_url.'" onclick="og.openLink(\''.$view_url.'\');return false;" title="'.$info->getFrom().'">';
				$conversation_block .= $from;
				if (!$is_current) $conversation_block .= '	</a><span class="desc">- '.$info_text.'</span></td>';
				
				$info_date = $info->getReceivedDate() instanceof DateTimeValue ? ($info->getReceivedDate()->isToday() ? format_time($info->getReceivedDate()) : format_datetime($info->getReceivedDate())) : lang('n/a');
				$conversation_block .= '</td><td style="text-align:right;padding-right:3px"><span class="desc">'. lang('date').': </span>'. $info_date .'</td>';

			} //foreach
			$conversation_block .= '</table>';
			$conversation_block .= '</div>';
		} else {
			$conversation_block = '';
Пример #30
0
/**
 * Return pick date widget
 *
 * @access public
 * @param string $name Name prefix
 * @param DateTimeValue $value Can be DateTimeValue object, integer or string
 * @param integer $year_from Start counting from this year. If NULL this value will be set
 *   to current year - 10
 * @param integer $year_to Count to this year. If NULL this value will be set to current
 * @deprecated
 *   year + 10
 * @return null
 */
function pick_date_widget($name, $value = null, $year_from = null, $year_to = null, $attributes = null, $id = null)
{
    require_javascript("og/DateField.js");
    $oldValue = $value;
    if (!$value instanceof DateTimeValue) {
        $value = new DateTimeValue($value);
    }
    $month_options = array();
    for ($i = 1; $i <= 12; $i++) {
        $option_attributes = $i == $value->getMonth() ? array('selected' => 'selected') : null;
        $month_options[] = option_tag(lang("month {$i}"), $i, $option_attributes);
    }
    // for
    $day_options = array();
    for ($i = 1; $i <= 31; $i++) {
        $option_attributes = $i == $value->getDay() ? array('selected' => 'selected') : null;
        $day_options[] = option_tag($i, $i, $option_attributes);
    }
    // for
    $year_from = (int) $year_from < 1 ? $value->getYear() - 10 : (int) $year_from;
    $year_to = (int) $year_to < 1 || (int) $year_to < $year_from ? $value->getYear() + 10 : (int) $year_to;
    $year_options = array();
    if ($year_from <= 1902) {
        $option_attributes = is_null($oldValue) ? array('selected' => 'selected') : null;
        $year_options[] = option_tag(lang('select'), 0, $option_attributes);
    }
    for ($i = $year_from; $i <= $year_to; $i++) {
        $option_attributes = $i == $value->getYear() && !is_null($oldValue) ? array('selected' => 'selected') : null;
        $year_options[] = option_tag($i, $i, $option_attributes);
    }
    // if
    $attM = $attributes;
    $attY = $attributes;
    $attD = $attributes;
    if ($attM['id']) {
        $attM['id'] .= '_month';
    }
    if ($attY['id']) {
        $attY['id'] .= '_year';
    }
    if ($attD['id']) {
        $attD['id'] .= '_day';
    }
    if (strpos($name, "]")) {
        $preName = substr_utf($name, 0, strpos_utf($name, "]"));
        return select_box($preName . '_month]', $month_options, $attM) . select_box($preName . '_day]', $day_options, $attD) . select_box($preName . '_year]', $year_options, $attY);
    } else {
        return select_box($name . '_month', $month_options, $attM) . select_box($name . '_day', $day_options, $attD) . select_box($name . '_year', $year_options, $attY);
    }
}