示例#1
0
 private function removeCronJob($startDate)
 {
     $cronDate = $this->cronDateTime($startDate);
     $needle = $cronDate['minute'] . " " . $cronDate['hour'] . " " . $cronDate['day'] . " " . $cronDate['month'] . " " . '*';
     $cron = new Crontab('nymedia_crontab');
     $cronJobs = $cron->getJobs();
     for ($i = 0; $i < count($cronJobs); $i++) {
         if ($cronJobs[$i]->getMinute() == $cronDate['minute'] && $cronJobs[$i]->getHour() == $cronDate['hour'] && $cronJobs[$i]->getDay() == $cronDate['day'] && $cronJobs[$i]->getMonth() == $cronDate['month']) {
             $cron->removeJob($i);
         }
     }
     $cron->saveCronFile();
     // save to my_crontab cronfile
     $cron->saveToCrontab();
     // adds all my_crontab jobs to system (replacing previous my_crontab jobs)
 }
示例#2
0
 public function editOrganization()
 {
     global $myconn;
     $private_key = $this->private_key;
     $opOrg = $myconn->prepare("SELECT * FROM " . db_table_pref . "organizations WHERE ID=?") or die(mysqli_error($myconn));
     $opOrg->bind_param('i', $this->OID);
     $opOrg->execute();
     $opOrg->store_result();
     if ($opOrg->num_rows == 0) {
         echo errMod('* ' . letheglobal_record_not_found . '', 'danger');
     } else {
         $sr = new Statement_Result($opOrg);
         $opOrg->fetch();
     }
     $this->errPrint = '';
     # Remove Organization
     if (!$sr->Get('isPrimary')) {
         if (isset($_POST['del']) && $_POST['del'] == 'YES') {
             # Remove Folder
             deleteAll(LETHE_RESOURCE . DIRECTORY_SEPARATOR . $sr->Get('orgTag'));
             # Remove Blacklist
             $myconn->query("DELETE FROM " . db_table_pref . "blacklist WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Autoresponder Actions
             $myconn->query("DELETE FROM " . db_table_pref . "campaign_ar WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Campaign Groups
             $myconn->query("DELETE FROM " . db_table_pref . "campaign_groups WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Campaigns
             $myconn->query("DELETE FROM " . db_table_pref . "campaigns WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Organization Settings
             $myconn->query("DELETE FROM " . db_table_pref . "organization_settings WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Organization
             $myconn->query("DELETE FROM " . db_table_pref . "organizations WHERE ID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Reports
             $myconn->query("DELETE FROM " . db_table_pref . "reports WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Short Codes
             $myconn->query("DELETE FROM " . db_table_pref . "short_codes WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Form Fields
             $myconn->query("DELETE FROM " . db_table_pref . "subscribe_form_fields WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Forms
             $myconn->query("DELETE FROM " . db_table_pref . "subscribe_forms WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Subscriber Groups
             $myconn->query("DELETE FROM " . db_table_pref . "subscriber_groups WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Subscribers
             $myconn->query("DELETE FROM " . db_table_pref . "subscribers WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Tasks
             $myconn->query("DELETE FROM " . db_table_pref . "tasks WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Templates
             $myconn->query("DELETE FROM " . db_table_pref . "templates WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Unsubscribes
             $myconn->query("DELETE FROM " . db_table_pref . "unsubscribes WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # User Permissions
             $myconn->query("DELETE FROM " . db_table_pref . "user_permissions WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Users
             $myconn->query("DELETE FROM " . db_table_pref . "users WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Cron Tasks
             include_once LETHE_ADMIN . DIRECTORY_SEPARATOR . 'classes/class.chronos.php';
             $letChr = new Crontab();
             $opCron = $myconn->query("SELECT * FROM " . db_table_pref . "chronos WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             while ($opCronRs = $opCron->fetch_assoc()) {
                 $letChr->removeJob($opCronRs['cron_command']);
             }
             $opCron->free();
             # Remove Crons
             $myconn->query("DELETE FROM " . db_table_pref . "chronos WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Done!
             header('Location: ?p=organizations/organization');
             return false;
             die;
         }
     }
     if (!isset($_POST['org_name']) || empty($_POST['org_name'])) {
         $this->errPrint .= '* ' . organizations_please_enter_a_organization_name . '<br>';
     }
     if (LETHE_AUTH_MODE == 2 && PRO_MODE) {
         if (!isset($_POST['org_max_user']) || !is_numeric($_POST['org_max_user'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_user_limit . '<br>';
         }
         if (!isset($_POST['org_max_newsletter']) || !is_numeric($_POST['org_max_newsletter'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_newsletter_limit . '<br>';
         }
         if (!isset($_POST['org_max_autoresponder']) || !is_numeric($_POST['org_max_autoresponder'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_autoresponder_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscriber']) || !is_numeric($_POST['org_max_subscriber'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscriber_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscriber_group']) || !is_numeric($_POST['org_max_subscriber_group'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscriber_group_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscribe_form']) || !is_numeric($_POST['org_max_subscribe_form'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscribe_form_limit . '<br>';
         }
         if (!isset($_POST['org_max_blacklist']) || !is_numeric($_POST['org_max_blacklist'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_black_list_limit . '<br>';
         }
         if (!isset($_POST['org_max_template']) || !is_numeric($_POST['org_max_template'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_template_limit . '<br>';
         }
         if (!isset($_POST['org_max_shortcode']) || !is_numeric($_POST['org_max_shortcode'])) {
             $this->errPrint .= '* ' . organizations_please_enter_maximum_short_code_limit . '<br>';
         }
         if (!isset($_POST['org_max_daily_limit']) || !is_numeric($_POST['org_max_daily_limit'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_daily_sending_limit . '<br>';
         }
         if (!isset($_POST['org_standby_organization']) || !is_numeric($_POST['org_standby_organization'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_standby_time_for_organizations . '<br>';
         }
     } else {
         $_POST['org_max_user'] = set_org_max_user;
         $_POST['org_max_newsletter'] = set_org_max_newsletter;
         $_POST['org_max_autoresponder'] = set_org_max_autoresponder;
         $_POST['org_max_subscriber'] = set_org_max_subscriber;
         $_POST['org_max_subscriber_group'] = set_org_max_subscriber_group;
         $_POST['org_max_subscribe_form'] = set_org_max_subscribe_form;
         $_POST['org_max_blacklist'] = set_org_max_blacklist;
         $_POST['org_max_template'] = set_org_max_template;
         $_POST['org_max_shortcode'] = set_org_max_shortcode;
         $_POST['org_max_daily_limit'] = set_org_max_daily_limit;
         $_POST['org_standby_organization'] = set_org_standby_organization;
     }
     /* Only For Super Admin */
     if (LETHE_AUTH_MODE == 2) {
         if (!isset($_POST['org_submission_account']) || count($_POST['org_submission_account']) == 0) {
             $this->errPrint .= '* ' . organizations_please_choose_a_submission_account . '<br>';
         } else {
             $_POST['org_submission_account'] = implode(',', $_POST['org_submission_account']);
         }
     } else {
         $_POST['org_submission_account'] = set_org_submission_account;
     }
     if (!isset($_POST['org_sender_title']) || empty($_POST['org_sender_title'])) {
         $this->errPrint .= '* ' . organizations_please_enter_a_sender_title . '<br>';
     }
     if (!isset($_POST['org_reply_mail']) || !mailVal($_POST['org_reply_mail'])) {
         $this->errPrint .= '* ' . organizations_invalid_reply_mail . '<br>';
     }
     if (!isset($_POST['org_test_mail']) || !mailVal($_POST['org_test_mail'])) {
         $this->errPrint .= '* ' . organizations_invalid_test_mail . '<br>';
     }
     if (!isset($_POST['org_timezone']) || empty($_POST['org_timezone'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_timezone . '<br>';
     }
     if (!isset($_POST['org_after_unsubscribe']) || !is_numeric($_POST['org_after_unsubscribe'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_unsubscribe_action . '<br>';
     }
     if (!isset($_POST['org_verification']) || !is_numeric($_POST['org_verification'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_verification_method . '<br>';
     }
     if (!isset($_POST['org_random_load']) || empty($_POST['org_random_load'])) {
         $_POST['org_random_load'] = '';
     } else {
         $_POST['org_random_load'] = 1;
     }
     if (!isset($_POST['org_load_type']) || !is_numeric($_POST['org_load_type'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_load_type . '<br>';
     }
     if ($this->errPrint == '') {
         /* Common Values */
         $this->isPrimary = $sr->Get('isPrimary');
         $billingDate = $this->billingDate == 0 ? '' : $this->billingDate;
         $orgTag = $this->orgTag == '' ? $sr->Get('orgTag') : $this->orgTag;
         $public_key = $this->public_key == '' ? $sr->Get('public_key') : $this->public_key;
         $private_key = $this->private_key == '' ? $sr->Get('private_key') : $this->private_key;
         # RSS Url
         if (!isset($_POST['org_rss_url']) || empty($_POST['org_rss_url'])) {
             # Define as system URL
             $_POST['org_rss_url'] = lethe_root_url . 'lethe.newsletter.php?pos=rss&oid=' . $public_key;
         } else {
             $_POST['org_rss_url'] = $_POST['org_rss_url'];
         }
         $addOrg = $myconn->prepare("UPDATE \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . db_table_pref . "organizations\n\t\t\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\t\t\t\t\torgTag=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\torgName=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbillingDate=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisActive=1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpublic_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprivate_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\trss_url=?\n\t\t\t\t\t\t\t\t\t\t\t  WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tID=" . $sr->Get('ID') . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t") or die(mysqli_error($myconn));
         $addOrg->bind_param('ssssss', $orgTag, $_POST['org_name'], $billingDate, $public_key, $private_key, $_POST['org_rss_url']);
         $addOrg->execute();
         $addOrg->close();
         /* Organization ID */
         $orgID = $sr->Get('ID');
         /* Load Settings */
         global $LETHE_ORG_SET_VALS;
         $addSet = $myconn->prepare("UPDATE " . db_table_pref . "organization_settings SET set_val=? WHERE OID=? AND set_key=?") or die(mysqli_error($myconn));
         foreach ($LETHE_ORG_SET_VALS as $k => $v) {
             if (!isset($_POST[$v])) {
                 $_POST[$v] = constant('set_' . $v);
             }
             $addSet->bind_param('sis', $_POST[$v], $orgID, $v);
             $addSet->execute();
         }
         $addSet->close();
         unset($_POST);
         $this->isSuccess = 1;
         $this->errPrint = errMod('' . letheglobal_updated_successfully . '!', 'success');
     } else {
         $this->errPrint = errMod($this->errPrint, 'danger');
     }
 }
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id)
	{
		$model=$this->loadModel($id);

		// comment the following line if AJAX validation is not needed
		 $this->performAjaxValidation($model);

		if(isset($_POST['ScheduleTiming']))
		{
			$model->attributes=$_POST['ScheduleTiming'];
			if($model->schedule_timing_minute==60)
			{
			  $minute="*";
			}
			else
			{
			  $minute=$model->schedule_timing_minute;
			}
			if($model->schedule_timing_hour==24)
			{
			  $hour="*";
			}
			else
			{
		          $hour=$model->schedule_timing_hour;
			}
			if($model->schedule_timing_date==32)
			{
				$date="*";
			}
			else
			{
				$date=$model->schedule_timing_date;
			}
			$days=array("Sunday"=>7,"Monday"=>1,"Tuesday"=>2,"Wednesday"=>3,"Thursday"=>4,"Friday"=>5,"Saturday"=>6,"*"=>"*");
			$day=$days[$model->schedule_timing_day];
			$months=array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12,'*'=>'*');
			$month=$months[$model->schedule_timing_month];
		
			$model->schedule_timing_name=$minute."-".$hour."-".$date."-".$model->schedule_timing_month."-".$model->schedule_timing_day;
			if($model->save())
			{
			$crons=StudentSmsEmailDetails::model()->findAll(array('condition'=>'student_sms_email_details_schedule_time_id='.$model->schedule_timing_id));
			$j = count($crons);
			$i = 0;

			foreach($crons as $cron)
			{
			    if($cron->student_sms_email_details_purpose=="fees")
			    {
				$period=$cron->academic_period_id;
				$sem=$cron->academic_name_id;
				$branch=$cron->branch_id;
				$div=$cron->division_id;
				$purpose=$cron->student_sms_email_details_purpose;
				$message=$cron->message_email_text;
				$user=$cron->created_by;
				$to=$cron->student_sms_email_details_fees_msg_type;
				$mobile=$cron->student_sms_email_details_to_mobile;
				$cronid=$cron->student_sms_email_details_cron_no-$i;
				$mycron = new Crontab('my_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
				$mycron = new Crontab('my_crontab'); 
				$cron->student_sms_email_details_cron_no=((count($mycron->getJobs())));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic feesschedulesms '.$period." ".$sem." ".$branch." ".$div." ".$purpose." \"$message\" ".$user." ".$to." ".$mobile , $minute, $hour,$date,$month,$day);
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
			     }
			     else
			     {
				$period=$cron->academic_period_id;
				$sem=$cron->academic_name_id;
				$branch=$cron->branch_id;
				$div=$cron->division_id;
				$purpose=$cron->student_sms_email_details_purpose;
				$user=$cron->created_by;
				$mobile=$cron->student_sms_email_details_to_mobile;
				$cronid=$cron->student_sms_email_details_cron_no-$i;
				$mycron = new Crontab('my_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
				$mycron = new Crontab('my_crontab'); 
				$cron->student_sms_email_details_cron_no=(count($mycron->getJobs()));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic attendance '.$period." ".$sem." ".$branch." ".$div." ".$purpose." ".$user." ".$mobile,$minute,$hour,$date,$month,$day);
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
			      }
			$i++;	
			}
			$backup_crons=DatabaseBackupCron::model()->findAll(array('condition'=>'database_backup_cron_schedule_time_id='.$model->schedule_timing_id));
			$j = count($backup_crons);
			$i = 0;

			foreach($backup_crons as $cron)
			{
				$cronid=$cron->database_backup_cron_no-$i;
				$mycron = new Crontab('backup_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				DatabaseBackupCron::model()->updateCounters(array('database_backup_cron_no'=>-1),'database_backup_cron_no>'.$cronid);
				$mycron = new Crontab('backup_crontab'); 
				$cron->database_backup_cron_no=((count($mycron->getJobs())));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic backup' , $minute, $hour,$date,$month,$day);	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				$i++;	
			}
			
				$this->redirect(array('view','id'=>$model->schedule_timing_id));
			}
		}
		$this->render('update',array(
			'model'=>$model,
		));
	}
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		$model=$this->loadModel($id);
		$cron = new Crontab('backup_crontab'); 
		$jobs_obj = $cron->getJobs();	
		$cron->removeJob($model->database_backup_cron_no); 			
		$cron->saveCronFile(); 	
		$cron->saveToCrontab();	
		$cronid=$model->database_backup_cron_no;
		DatabaseBackupCron::model()->updateCounters(array('database_backup_cron_no'=>-1),'database_backup_cron_no>'.$cronid);

		// we only allow deletion via POST request
		$this->loadModel($id)->delete();

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_GET['ajax']))
	 	  $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
	}
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		$model=$this->loadModel($id);
		$cron = new Crontab('my_crontab'); 
		$jobs_obj = $cron->getJobs();	
		$cron->removeJob($model->student_sms_email_details_cron_no); 			
		$cron->saveCronFile(); 	
		$cron->saveToCrontab();	
		$cronid=$model->student_sms_email_details_cron_no;
		StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
		$this->loadModel($id)->delete();
		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_GET['ajax']))
			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('scheduleMessages'));
	}
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		if(Yii::app()->request->isPostRequest)
		{
			// we only allow deletion via POST request
			// we only allow deletion via POST request
			$model=$this->loadModel($id);
			$cron = new Crontab('mail_crontab'); 
			$jobs_obj = $cron->getJobs();	
			$cron->removeJob($model->student_attendence_email_cron_no); 				$cron->saveCronFile(); 	
			$cron->saveToCrontab();	
			$cronid=$model->student_attendence_email_cron_no;
			StudentAttendenceEmail::model()->updateCounters(array('student_attendence_email_cron_no'=>-1),'student_attendence_email_cron_no>'.$cronid);
			$this->loadModel($id)->delete();

			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
			if(!isset($_GET['ajax']))
				$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
		}
		else
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
	}