public function Insert()
 {
     $_POST['manager_password'] = Password($_POST['manager_password']);
     $date = TDate::GetInstance();
     //        $_POST['manager_register_time'] = time();
     //        $_POST['manager_active_time'] = $date->Persi2Timestamp($_POST['manager_active_time']);
     $id = $this->model->Create($_POST);
     Redirect(UR_MP . 'Manager/Edit/' . $id);
 }
 public function Update($id)
 {
     if ($_POST['member_password'] == '') {
         unset($_POST['member_password']);
     } else {
         $_POST['member_password'] = Password($_POST['member_password']);
     }
     $date = TDate::GetInstance();
     $_POST['member_active_time'] = $date->Persi2Timestamp($_POST['member_active_time']);
     $this->model->Edit($id, $_POST);
     Redirect(UR_MP . 'Member/Edit/' . $id);
 }
示例#3
0
 /**
  * set upload mode
  * @param int $upload_mode upload const
  * @param strimg $other other name
  * @return type
  */
 function __construct($upload_mode = UPLOAD_BY_DATE, $other = '')
 {
     // pre
     _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $upload_mode, $other);
     if ($upload_mode == UPLOAD_BY_DATE) {
         $date = TDate::GetInstance();
         $this->upload_dir = '../upload/file/' . $date->SDate('Y/m');
     } else {
         $this->upload_dir = '../upload/file/type';
     }
     if (!file_exists($this->upload_dir)) {
         mkdir($this->upload_dir, 0777, true);
     }
     $this->upload_mode = $upload_mode;
     if ($other != '') {
         $this->upload_dir = '../upload/' . $other;
     }
     // result hook
     _hk('R' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $upload_mode);
     return $upload_mode;
 }
示例#4
0
<?php

//var_dump($this->record);
$date = TDate::GetInstance();
$frm = new TForm(UR_MP . 'Member/Update/' . $this->record['member_id'], 'post', array('class' => 'form rtl'));
$frm->AddField('text', 'نام', $this->record['member_name'], array('name' => 'member_name'));
$frm->AddField('email', 'ایمیل', $this->record['member_email'], array('name' => 'member_email'));
$frm->AddField('password', 'گذرواژه', null, array('name' => 'member_password'));
$frm->AddField('text', 'استاتوس', $this->record['member_status'], array('name' => 'member_status'));
$frm->AddField('text', 'زمان تمدید', $date->PDate('Y/m/d', $this->record['member_active_time']), array('name' => 'member_active_time', 'class' => _lg('datepicker')));
$frm->AddField('file', 'آواتار', $this->record['member_id'], array('name' => 'member_avatar'));
$frm->AddField('text', 'مقطع', $this->record['member_degree'], array('name' => 'member_degree'));
$frm->AddField('text', 'رشته تحصیلی', $this->record['member_field'], array('name' => 'member_field'));
$frm->AddField('text', 'شماره تماس', $this->record['member_number'], array('name' => 'member_number'));
$frm->AddField('text', 'شهر', $this->record['member_city'], array('name' => 'member_city'));
$frm->AddField('textarea', 'توصیه مشاور/ پشتیبان', $this->record['member_comment'], array('name' => 'member_comment', 'class' => 'full-width'));
$frm->AddField('select', 'نوع', $this->record['member_type'], array('name' => 'member_type'), array(0 => array('0', 'تایید نشده'), 1 => array('1', 'تایید شده'), 2 => array('2', 'اخراجی')));
$frm->AddField('select', 'وضعیت چت', $this->record['member_chat'], array('name' => 'member_chat'), array(0 => array('1', ' فعال'), 1 => array('0', 'اخراجی')));
$frm->AddField('submit', '', 'ویرایش');
//print_r($this->reports);
?>
<br />
<h2 class="rtl">
    <?php 
echo $this->title;
?>
</h2>
<br />
<br />
<div class="row">
    <div class="grd-primary">
示例#5
0
function ShowCommentByParent($topic_id, $parent, $is_child)
{
    $date = TDate::GetInstance();
    global $database_handle;
    $sql = "SELECT comment_id,comment_member_id,comment_time,comment_text\n            , m.member_name, f.manager_displayname \n            FROM " . DB_PREFIX . "comment c\n            LEFT JOIN " . DB_PREFIX . "member m on m.member_id = c.comment_member_id\n            LEFT JOIN " . DB_PREFIX . "manager f on f.manager_id = c.comment_member_id*-1  " . " WHERE comment_parent = :par AND comment_topic_id = :id AND comment_status = 1 " . " ORDER BY comment_id DESC ";
    $ret = $database_handle->Select($sql, array('comment'), array(':par' => $parent, ':id' => $topic_id));
    $result = null;
    foreach ($ret as $comment) {
        $result .= '<li>';
        $result .= '<div class="head">
                        <img alt="[avatar]" src="/upload/member/' . $comment['comment_member_id'] . '.jpg" class="avatar">
                        ';
        if (isset($_COOKIE['mid'])) {
            $result .= '<button class="reply left" data-id="' . $comment['comment_id'] . '"> پاسخ</button>';
        }
        if ($comment['comment_member_id'] > 0) {
            $result .= '<a href="/member/' . $comment['comment_member_id'] . '/' . $comment['member_name'] . '">';
        }
        $result .= '<span class="author">
                            ' . $comment['manager_displayname'] . $comment['member_name'] . '
                        </span>';
        if ($comment['comment_member_id'] > 0) {
            $result .= '</a>';
        }
        $result .= '<span class="date">
                            ' . $date->RDate($comment['comment_time']) . '
                        </span>
                    </div>
                    <p>
                        ' . $comment['comment_text'] . '
                    </p>';
        if ($is_child && CommentChildCount($topic_id, $comment['comment_id']) > 0) {
            $result .= '<ul>';
            $result .= ShowCommentByParent($topic_id, $comment['comment_id'], $is_child);
            $result .= '</ul>';
        }
        $result .= '</li>';
    }
    return $result;
}
示例#6
0
 /**
  * render listview and show
  * @param string $location base of controller class name
  */
 public function Render($location = '')
 {
     $date_format = 'Y/m/d H:i';
     // pre hook
     _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $location, $date_format);
     $date = TDate::GetInstance();
     $result = null;
     // show saerch or item
     if ($this->search != null || $this->relation != array()) {
         $result .= '<div class="listview-search row" action="' . UR_MP . $location . '" >';
         // show search here
         if ($this->search != null) {
             //            die($prefix);
             $result .= '<form class="grd12"  action="' . UR_MP . $location . '">';
             $result .= '<input type="text" name="search" class="search-box" placeholder="' . _lg('Search') . '..." />';
             $result .= '<input type="hidden" name="fields" class="search-fields" value="' . $this->search . '"  />';
             if (isset($_GET['filter'])) {
                 $result .= '<input type="hidden" name="filter" value="' . $_GET['filter'] . '"  />';
             }
             $result .= '&nbsp;<button><span class="fa fa-search"></span></button>';
             if (isset($_GET['search']) && $_GET['search'] != '') {
                 $result .= '&nbsp;<button onclick="$(this).parent().find(\'.search,.search-fields\').remove();"><span class="fa fa-close"></span></button>';
             }
             $result .= '</form>';
         }
         // relation info
         if ($this->relation != array()) {
             $md = new TModel($this->relation['table']);
             $result .= '<form class="grd12 "  action="' . UR_MP . $location . '">' . ($this->relation['ico'] != '' ? '<span class="fa fa-' . $this->relation['ico'] . '"></span>' : '') . '<select name="rel" class="rel">';
             $result .= '<option value="0" >' . _lg('Select an item to search') . '</option>';
             foreach ($md->Selectable($this->relation['title'], $this->relation['value']) as $item) {
                 $result .= '<option value="' . $item[0] . '" ' . (isset($_GET['rel']) && $_GET['rel'] == $item[0] ? 'selected="selected"' : '') . ' >' . $item[1] . '</option>';
             }
             $result .= '</select>';
             $result .= '<input type="hidden" name="typ" class="rel-type" value="' . $this->relation['rel_type'] . '" />';
             $result .= '&nbsp;<button><span class="fa fa-search"></span></button>';
             if (isset($_GET['rel']) && $_GET['rel'] != '') {
                 $result .= '&nbsp;<button onclick="$(this).parent().find(\'.rel,.rel-type\').remove();"><span class="fa fa-close"></span></button>';
             }
             $result .= '</form>';
         }
         $result .= '</div>';
     }
     // show all filter here
     if ($this->filter['title'] != array()) {
         $result .= '<div class="filter">';
         // get prefix
         $prefix = GetLinkPrefix('filter');
         // show title and no filter item named "All";
         $result .= '<span> ' . _lg('Filter') . ': </span> <a class="button" href="' . $prefix . '"> ' . _lg('All') . '</a>';
         // show filter lisr
         foreach ($this->filter['title'] as $key => $value) {
             $result .= '<a class="button" href="' . $prefix . 'filter=' . $this->filter['key'][$key] . ',' . $this->filter['value'][$key] . '">' . $value . '</a>';
         }
         $result .= '</div>';
     }
     // get order by column
     $prefix = GetLinkPrefix('order,desc');
     // get id order and choose good value for this
     if (isset($_GET['order']) && $_GET['order'] == $this->id) {
         $id_order = $prefix;
     } else {
         $id_order = $prefix . 'order=' . $this->id;
     }
     // show form head here when have bulk action
     if ($this->bulk_action['title'] != array()) {
         $result .= '<form method="post" action="' . UR_MP . $location . '/BulkAction">';
     }
     //start render listview header
     // start with bulk action checkbox and id header
     $result .= '<ul class="listview">
 <li class="pinned animate"> 
     <div  class="row">
         <div class="grd1"> <input type="checkbox" class="checkall" />  </div>
         <a href="' . $id_order . '"><div class="grd2 header"> ' . _lg('no.') . ' </div></a>';
     // show header column title
     foreach ($this->column['title'] as $key => $value) {
         if (substr($this->column['key'][$key], 0, 1) == '%') {
             $col_name = substr($this->column['key'][$key], 2);
         } else {
             $col_name = $this->column['key'][$key];
         }
         $result .= '<a href="' . $prefix . 'order=' . $col_name . (!isset($_GET['desc']) && isset($_GET['order']) && $_GET['order'] == $col_name ? '&desc=1' : '') . '"><div class="grd' . $this->column['size'][$key] . '">' . $value . '</div></a>';
     }
     // action haader
     $result .= '<div class="grd' . $this->action['size'] . '"> &nbsp; </div>';
     $result .= '</div>
 </li>';
     // show all records in this page
     foreach ($this->assoc_list as $record) {
         //start with bulk action checkbox and id
         $result .= '<li> 
     <div  class="row">';
         $result .= '<div class="grd1">' . PHP_EOL . ' <input type="checkbox" ' . 'class="listview-checkbox" name="id[]" value="' . $record[$this->id] . '" />' . PHP_EOL . ' </div>' . PHP_EOL;
         $result .= '<div class="grd2"> ' . $record[$this->id] . ' </div>';
         // show record columns added before by size
         foreach ($this->column['key'] as $key => $value) {
             if (strpos($value, ',') == false) {
                 $result .= PHP_EOL . '<div class="grd' . $this->column['size'][$key] . '">' . PHP_EOL;
                 switch (substr($value, 0, 2)) {
                     case '%i':
                         $a = substr($value, 2);
                         $result .= long2ip($record[$a]);
                         break;
                     case '%t':
                         $a = substr($value, 2);
                         $result .= $date->PDate($date_format, $record[$a]);
                         break;
                         // show array
                     // show array
                     case '%a':
                         $a = substr($value, 2);
                         $v = explode('|', $a);
                         $arr = $v[0];
                         global ${$arr};
                         $array = ${$arr};
                         $result .= $array[$record[$v[1]]];
                         break;
                     case '%1':
                     case '%2':
                     case '%3':
                     case '%4':
                     case '%5':
                     case '%6':
                     case '%7':
                     case '%8':
                     case '%9':
                         $p = substr($value, 1, 1);
                         $a = substr($value, 2);
                         $result .= sprintf($this->pattren[$p], $record[$a]);
                         break;
                     default:
                         $result .= $record[$value];
                         break;
                 }
                 $result .= '</div>' . PHP_EOL;
             } else {
                 $temp = explode(',', $value);
                 $result .= PHP_EOL . '<div class="grd' . $this->column['size'][$key] . '">';
                 foreach ($temp as $col) {
                     $result .= $record[$col] . PHP_EOL;
                 }
                 $result .= '</div>' . PHP_EOL;
             }
         }
         // add action to record
         $result .= PHP_EOL . '<div class="grd' . $this->action['size'] . ' c' . ($this->action['class'] == '' ? '' : $record[$this->action['class']]) . '">';
         $tmp = str_replace("%id%", $record[$this->id], $this->action['pattern']);
         if ($this->id == 'comment_id') {
             $result .= str_replace("%topic%", $record['comment_topic_id'], $tmp);
         } else {
             $result .= $tmp;
         }
         $result .= '</div>' . PHP_EOL;
         $result .= '</div>' . PHP_EOL . '</li>' . PHP_EOL;
     }
     $result .= '</ul>' . PHP_EOL;
     // if have bulk action show this after list view
     if ($this->bulk_action['title'] != array()) {
         $result .= '<div class="bulk-action">
                 <select name="action">';
         // list of bulk actions
         foreach ($this->bulk_action['function'] as $key => $value) {
             $result .= '<option  value="' . $value . ',' . $this->bulk_action['value'][$key] . '">' . $this->bulk_action['title'][$key] . '</option>';
         }
         $result .= '</select>';
         $result .= '<input type="submit" value="' . _lg('Bulk apply') . '" />' . '<div class="left" > ' . '<input type="button" value="' . _lg('Check All') . '" class="chkall" data-chekbox="listview-checkbox" /> ' . '<input type="button" value="' . _lg('Check None') . '" class="chknone" data-chekbox="listview-checkbox" /> ' . '<input type="button" value="' . _lg('Check Toggle') . '" class="chktoggle" data-chekbox="listview-checkbox" /> ' . '</div>' . '</div>' . '</form>';
     }
     // result hook
     _hk('R' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $result);
     echo $result;
 }